2020-04-03 01:39:10 +03:00
|
|
|
function lean_pwd
|
2020-04-30 00:52:58 +03:00
|
|
|
set -l pwdSplit (string split --no-empty '/' (_shorten_pwd))
|
2020-04-13 22:57:21 +03:00
|
|
|
set -l pwdSplitLength (count $pwdSplit)
|
2020-04-03 01:39:10 +03:00
|
|
|
|
2020-04-28 23:46:40 +03:00
|
|
|
if not test -w $PWD
|
|
|
|
set_color $lean_color_dark_blue
|
2020-04-30 05:19:17 +03:00
|
|
|
echo -n {$lean_pwd_unwritable_icon}' '
|
2020-04-28 23:46:40 +03:00
|
|
|
set_color $fish_color_normal
|
|
|
|
end
|
|
|
|
|
2020-04-30 00:52:58 +03:00
|
|
|
if test "$pwdSplit[1]" != '~'
|
2020-04-25 06:56:17 +03:00
|
|
|
set_color $lean_color_dark_blue
|
2020-04-30 00:52:58 +03:00
|
|
|
echo -n '/'
|
2020-04-03 01:39:10 +03:00
|
|
|
set_color $fish_color_normal
|
2020-04-25 06:56:17 +03:00
|
|
|
end
|
2020-04-03 01:39:10 +03:00
|
|
|
|
2020-04-25 06:56:17 +03:00
|
|
|
set_color -o $lean_color_light_blue
|
|
|
|
echo -n $pwdSplit[1]
|
|
|
|
set_color $fish_color_normal
|
|
|
|
|
|
|
|
if test $pwdSplitLength -gt 1
|
2020-04-23 01:19:58 +03:00
|
|
|
set_color $lean_color_dark_blue
|
2020-04-30 00:52:58 +03:00
|
|
|
echo -n '/'
|
2020-04-23 01:19:58 +03:00
|
|
|
set_color $fish_color_normal
|
2020-04-03 01:39:10 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
if test $pwdSplitLength -gt 2
|
2020-04-25 06:56:17 +03:00
|
|
|
set_color $lean_color_dark_blue
|
2020-04-30 05:19:17 +03:00
|
|
|
echo -n (string join '/' $pwdSplit[2..-2])'/'
|
2020-04-25 06:56:17 +03:00
|
|
|
set_color $fish_color_normal
|
2020-04-03 01:39:10 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
if test $pwdSplitLength -gt 1
|
2020-04-25 06:56:17 +03:00
|
|
|
set_color -o $lean_color_light_blue
|
2020-04-03 01:39:10 +03:00
|
|
|
echo -n $pwdSplit[-1]
|
2020-04-25 06:56:17 +03:00
|
|
|
set_color $fish_color_normal
|
2020-04-03 01:39:10 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function _shorten_pwd
|
2020-04-23 01:19:58 +03:00
|
|
|
set -l pwd (prompt_pwd)
|
|
|
|
|
|
|
|
if test "$pwd" = "$previousPwd"
|
|
|
|
echo $pwd
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
set -g fish_prompt_pwd_dir_length 0
|
|
|
|
set -l pwd (prompt_pwd)
|
|
|
|
set -l lengthPromptPwd (string length $pwd)
|
2020-04-29 07:19:32 +03:00
|
|
|
set -l shortenPwdLength (math $COLUMNS-$lean_pwd_shorten_margin)
|
2020-04-03 01:39:10 +03:00
|
|
|
|
2020-04-25 06:56:17 +03:00
|
|
|
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)
|
2020-04-03 01:39:10 +03:00
|
|
|
end
|
|
|
|
|
2020-04-23 01:19:58 +03:00
|
|
|
set -g previousPwd (prompt_pwd)
|
|
|
|
|
|
|
|
echo $pwd
|
2020-04-03 01:39:10 +03:00
|
|
|
end
|