1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-24 21:31:58 +00:00

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.

This commit is contained in:
L.C. Karssen 2015-07-27 23:00:35 +02:00
parent 18801e25d2
commit 63e216ba9d

View file

@ -1,17 +1,25 @@
# AVIT ZSH Theme # AVIT ZSH Theme
PROMPT=' PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version) $(_user_host)$(_current_dir) $(git_prompt_info) $(_ruby_version)
%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} ' %{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
PROMPT2='%{$fg[grey]%}◀%{$reset_color%} ' PROMPT2='%{$fg[grey]%}◀%{$reset_color%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}' 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 _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
local _hist_no="%{$fg[grey]%}%h%{$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() { function _user_host() {
if [[ -n $SSH_CONNECTION ]]; then if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m" me="%n@%m"