tide/functions/_tide_pwd.fish

31 lines
1.3 KiB
Fish
Raw Normal View History

2020-06-06 20:40:14 +03:00
function _tide_pwd
set -l truncatedPwd $_tide_pwd
set -l colorDirs (set_color $tide_pwd_color_dirs)
set -g _tide_pwd_output $colorDirs$_tide_pwd
2020-06-06 20:40:14 +03:00
2020-07-12 02:45:23 +03:00
if not test -w $PWD
set _tide_pwd_output $colorDirs{$tide_pwd_unwritable_icon}' ' $_tide_pwd_output
2020-06-06 20:40:14 +03:00
end
2020-06-07 19:40:42 +03:00
set -l truncatedList '.' $_tide_split_pwd
2020-06-06 20:40:14 +03:00
for dir in $_tide_split_pwd
if contains $dir $_tide_pwd_anchors
2020-06-25 05:47:15 +03:00
set _tide_pwd_output (string replace $dir (set_color -o $tide_pwd_color_anchors)$dir(set_color normal -b $tide_pwd_bg_color) $_tide_pwd_output)
2020-07-11 05:25:02 +03:00
else if test (string length $truncatedPwd) -gt $_tide_pwd_max_length
set -l dirTruncated $dir
set -l truncationLength 1
while contains $dirTruncated $truncatedList
set dirTruncated (string sub -l $truncationLength $dir)
set truncationLength (math $truncationLength+1)
2020-06-06 20:40:14 +03:00
end
2020-07-11 05:25:02 +03:00
set -a truncatedList $dirTruncated
set truncatedPwd (string replace $dir $dirTruncated $truncatedPwd)
set _tide_pwd_output (string replace $dir (set_color $tide_pwd_color_truncated_dirs)$dirTruncated $_tide_pwd_output)
2020-06-06 20:40:14 +03:00
end
end
set _tide_pwd_output (string replace -a '/' $colorDirs'/' $_tide_pwd_output)
2020-06-06 20:40:14 +03:00
end