Truncated pwd

This commit is contained in:
Thomas Forgione 2017-08-10 10:45:44 +00:00
parent 93b879710b
commit 673279173d
No known key found for this signature in database
GPG Key ID: 95D964F74A96119E
1 changed files with 10 additions and 1 deletions

View File

@ -45,9 +45,18 @@ else
fi
# local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})"
truncated_pwd() {
current_pwd=$(print -rD $PWD)
if [ ${#current_pwd} -gt 50 ]; then
last_dirs=`echo ${current_pwd: -50} | cut -d '/' -f 2-`
echo "~/.../${last_dirs}"
else
echo $current_pwd
fi
}
local user_host='$PR_BOLD${PR_USER}$PR_BOLD'
local current_dir='$PR_BOLD%{$PR_BLUE%}%~%{$PR_NO_COLOR%}'
local current_dir='$PR_BOLD%{$PR_BLUE%}$(truncated_pwd)$PR_NO_COLOR%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='%{$PR_RED%}$(rvm-prompt i v g s)%{$PR_NO_COLOR%}'