I'm fucking awesome

This commit is contained in:
Thomas Forgione 2018-03-28 06:17:07 +02:00
parent 93ad9c6df3
commit 12307ae0dc
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
1 changed files with 10 additions and 5 deletions

View File

@ -46,12 +46,17 @@ fi
# local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})" # local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})"
truncated_pwd() { truncated_pwd() {
current_pwd=$(print -rD $PWD) local max_allowed_size=$(( `tput cols` - 30 ))
if [ ${#current_pwd} -gt 50 ]; then local path_name=$(print -rD $PWD)
last_dirs=`echo ${current_pwd: -50} | cut -d '/' -f 2-` local truncated=0
echo "~/.../${last_dirs}" while [ ${#path_name} -gt $max_allowed_size ]; do
truncated=1
path_name=`echo $path_name | cut -d '/' -f 2-`
done
if [ $truncated -eq 1 ]; then
echo "~/.../"$path_name
else else
echo $current_pwd echo $path_name
fi fi
} }