diff options
author | L.C. Karssen <lennart@karssen.org> | 2015-07-27 23:00:35 +0200 |
---|---|---|
committer | L.C. Karssen <lennart@karssen.org> | 2016-01-13 10:00:32 +0100 |
commit | 63e216ba9d20cb5960aaa59e4bc38405dd03c52c (patch) | |
tree | 55c598fa0e5eedc64c4be623cf1c898985b09e2d /themes/avit.zsh-theme | |
parent | 18801e25d26c6a10c39e9ef9eeecd8921e9de4c7 (diff) | |
download | zsh-63e216ba9d20cb5960aaa59e4bc38405dd03c52c.tar.gz zsh-63e216ba9d20cb5960aaa59e4bc38405dd03c52c.tar.bz2 zsh-63e216ba9d20cb5960aaa59e4bc38405dd03c52c.zip |
oh-my-zsh avit theme: instead of only showing the last 3 directories in the $PWD shorten the path by removing some middle parts if $PWD becomes too long.
Diffstat (limited to 'themes/avit.zsh-theme')
-rw-r--r-- | themes/avit.zsh-theme | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index fc6b00455..b5a05799e 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -1,17 +1,25 @@ # AVIT ZSH Theme PROMPT=' -$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version) +$(_user_host)$(_current_dir) $(git_prompt_info) $(_ruby_version) %{$fg[$CARETCOLOR]%}▶%{$resetcolor%} ' PROMPT2='%{$fg[grey]%}◀%{$reset_color%} ' RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}' -local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} " local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}" local _hist_no="%{$fg[grey]%}%h%{$reset_color%}" +function _current_dir() { + local _max_pwd_length="65" + if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then + echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} " + else + echo "%{$fg_bold[blue]%}%~%{$reset_color%} " + fi +} + function _user_host() { if [[ -n $SSH_CONNECTION ]]; then me="%n@%m" |