diff --git a/zsh/oh-my-zsh/themes/laptop.zsh-theme b/zsh/oh-my-zsh/themes/laptop.zsh-theme index d9dd8a7..2bb9774 100644 --- a/zsh/oh-my-zsh/themes/laptop.zsh-theme +++ b/zsh/oh-my-zsh/themes/laptop.zsh-theme @@ -46,12 +46,17 @@ 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}" + local max_allowed_size=$(( `tput cols` - 30 )) + local path_name=$(print -rD $PWD) + local truncated=0 + 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 - echo $current_pwd + echo $path_name fi }