63e216ba9d20cb5960aaa59e4bc38405dd03c52c

Author
L.C. Karssen <lennart@karssen.org>
Committer
L.C. Karssen <lennart@karssen.org>
Date

Message

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.

Diff

 1diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
 2index fc6b004557bc7043bc20039aa2922dd0a1b1be1d..b5a05799eb18d2d3ba0750fe76c6a004861aff27 100644
 3--- a/themes/avit.zsh-theme
 4+++ b/themes/avit.zsh-theme
 5@@ -1,17 +1,25 @@
 6 # AVIT ZSH Theme
 7 
 8 PROMPT='
 9-$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
10+$(_user_host)$(_current_dir) $(git_prompt_info) $(_ruby_version)
11 %{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
12 
13 PROMPT2='%{$fg[grey]%}◀%{$reset_color%} '
14 
15 RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
16 
17-local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
18 local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
19 local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
20 
21+function _current_dir() {
22+  local _max_pwd_length="65"
23+  if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then
24+    echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} "
25+  else
26+    echo "%{$fg_bold[blue]%}%~%{$reset_color%} "
27+  fi
28+}
29+
30 function _user_host() {
31   if [[ -n $SSH_CONNECTION ]]; then
32     me="%n@%m"