Fix lean_pwd. Minor edits

This commit is contained in:
Ilan Cosman 2020-04-24 20:56:17 -07:00
parent 2861ea580e
commit bba6e423e5
6 changed files with 47 additions and 43 deletions

View File

@ -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

View File

@ -1,5 +1,4 @@
function lean_load_right_prompt_modules
set -g lean_right_prompt_modules_order leanTimer
set -g leanTimer (_lean_timer)
end

View File

@ -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)

View File

@ -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

View File

@ -1,5 +1,7 @@
function _lean_right_prompt_nocolor
echo -n " "
echo -n $leanTimer
echo -n " "
end
if test -n "$leanTimer"
echo -n $leanTimer
echo -n " "
end
end

View File

@ -1,5 +1,7 @@
function _lean_right_prompt_nocolor
echo -n " "
echo -n $leanTimer
echo -n " "
end
if test -n "$leanTimer"
echo -n $leanTimer
echo -n " "
end
end