diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 019c5ec..fcd9975 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -26,7 +26,10 @@ end function _lean_right_prompt_nocolor echo -n " " - echo -n $leanTimer - echo -n " " + if test -n "$leanTimer" + echo -n $leanTimer + echo -n " " + end end + diff --git a/functions/lean_load_right_prompt_modules.fish b/functions/lean_load_right_prompt_modules.fish index 8bf2604..b6b72b9 100644 --- a/functions/lean_load_right_prompt_modules.fish +++ b/functions/lean_load_right_prompt_modules.fish @@ -1,5 +1,4 @@ function lean_load_right_prompt_modules - set -g lean_right_prompt_modules_order leanTimer set -g leanTimer (_lean_timer) end diff --git a/functions/lean_pwd.fish b/functions/lean_pwd.fish index d0c02ba..60d598a 100644 --- a/functions/lean_pwd.fish +++ b/functions/lean_pwd.fish @@ -1,35 +1,35 @@ function lean_pwd - set -l pwdSplit (string split "/" (_shorten_pwd)) + set -l pwdSplit (string split --no-empty "/" (_shorten_pwd)) set -l pwdSplitLength (count $pwdSplit) - if test $pwdSplit[1] = "~" - set_color -o $lean_color_light_blue - echo -n "~" - set_color $fish_color_normal - - if test $pwdSplitLength -gt 1 - set_color $lean_color_dark_blue - echo -n "/" - set_color $fish_color_normal - end - else + if test $pwdSplit[1] != "~" set_color $lean_color_dark_blue echo -n "/" set_color $fish_color_normal end - set_color $lean_color_dark_blue - echo -n (string join "/" $pwdSplit[2..-2]) - if test $pwdSplitLength -gt 2 - echo -n "/" - end + set_color -o $lean_color_light_blue + echo -n $pwdSplit[1] set_color $fish_color_normal - set_color -o $lean_color_light_blue if test $pwdSplitLength -gt 1 - echo -n $pwdSplit[-1] + set_color $lean_color_dark_blue + echo -n "/" + set_color $fish_color_normal + end + + if test $pwdSplitLength -gt 2 + set_color $lean_color_dark_blue + echo -n (string join "/" $pwdSplit[2..-2]) + echo -n "/" + set_color $fish_color_normal + end + + if test $pwdSplitLength -gt 1 + set_color -o $lean_color_light_blue + echo -n $pwdSplit[-1] + set_color $fish_color_normal end - set_color $fish_color_normal end function _shorten_pwd @@ -45,16 +45,12 @@ function _shorten_pwd set -l lengthPromptPwd (string length $pwd) set -l shortenPwdLength (math $COLUMNS-$lean_shorten_pwd_margin) - if test $lengthPromptPwd -gt $shortenPwdLength - for promptPwdDirLength in 8 7 6 5 4 3 - set fish_prompt_pwd_dir_length $promptPwdDirLength - set pwd (prompt_pwd) - set lengthPromptPwd (string length $pwd) - - if test $lengthPromptPwd -lt $shortenPwdLength - break - end - end + set -l promptPwdDirLength 8 + while test $lengthPromptPwd -gt $shortenPwdLength -a $promptPwdDirLength -gt 0 + set fish_prompt_pwd_dir_length $promptPwdDirLength + set pwd (prompt_pwd) + set lengthPromptPwd (string length $pwd) + set promptPwdDirLength (math $promptPwdDirLength-1) end set -g previousPwd (prompt_pwd) diff --git a/functions/lean_right_prompt.fish b/functions/lean_right_prompt.fish index 4e6d361..4762f4a 100644 --- a/functions/lean_right_prompt.fish +++ b/functions/lean_right_prompt.fish @@ -1,7 +1,9 @@ function lean_right_prompt echo -n " " - set_color $lean_timer_color - echo -n $leanTimer - set_color normal - echo -n " " + if test -n "$leanTimer" + set_color $lean_timer_color + echo -n $leanTimer + set_color normal + echo -n " " + end end \ No newline at end of file diff --git a/lean_theme/prompt_modules/fake_prompt/5_rPromptNoColor.fish b/lean_theme/prompt_modules/fake_prompt/5_rPromptNoColor.fish index b5ec5dd..1954a62 100644 --- a/lean_theme/prompt_modules/fake_prompt/5_rPromptNoColor.fish +++ b/lean_theme/prompt_modules/fake_prompt/5_rPromptNoColor.fish @@ -1,5 +1,7 @@ function _lean_right_prompt_nocolor echo -n " " - echo -n $leanTimer - echo -n " " -end \ No newline at end of file + if test -n "$leanTimer" + echo -n $leanTimer + echo -n " " + end +end diff --git a/lean_theme/prompt_modules/fish_prompt/5_rPromptNoColor.fish b/lean_theme/prompt_modules/fish_prompt/5_rPromptNoColor.fish index b5ec5dd..1954a62 100644 --- a/lean_theme/prompt_modules/fish_prompt/5_rPromptNoColor.fish +++ b/lean_theme/prompt_modules/fish_prompt/5_rPromptNoColor.fish @@ -1,5 +1,7 @@ function _lean_right_prompt_nocolor echo -n " " - echo -n $leanTimer - echo -n " " -end \ No newline at end of file + if test -n "$leanTimer" + echo -n $leanTimer + echo -n " " + end +end