Even better

This commit is contained in:
Thomas Forgione 2018-03-28 06:19:48 +02:00
parent 12307ae0dc
commit 95327a4404
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
1 changed files with 6 additions and 1 deletions

View File

@ -48,10 +48,15 @@ fi
truncated_pwd() {
local max_allowed_size=$(( `tput cols` - 30 ))
local path_name=$(print -rD $PWD)
local new_path_name=""
local truncated=0
while [ ${#path_name} -gt $max_allowed_size ]; do
truncated=1
path_name=`echo $path_name | cut -d '/' -f 2-`
new_path_name=`echo $path_name | cut -d '/' -f 2-`
if [[ "$new_path_name" == "$path_name" ]]; then
break
fi
path_name=$new_path_name
done
if [ $truncated -eq 1 ]; then
echo "~/.../"$path_name