From 95327a44049af1a7503babe95b91114212cee76c Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Wed, 28 Mar 2018 06:19:48 +0200 Subject: [PATCH] Even better --- zsh/oh-my-zsh/themes/laptop.zsh-theme | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zsh/oh-my-zsh/themes/laptop.zsh-theme b/zsh/oh-my-zsh/themes/laptop.zsh-theme index 2bb9774..9ce2023 100644 --- a/zsh/oh-my-zsh/themes/laptop.zsh-theme +++ b/zsh/oh-my-zsh/themes/laptop.zsh-theme @@ -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