2020-06-06 20:40:14 +03:00
|
|
|
function _tide_pwd
|
|
|
|
set -l truncatedPwd $_tide_pwd
|
2020-06-23 02:18:51 +03:00
|
|
|
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
|
|
|
|
|
|
|
if not test -w $PWD
|
2020-06-28 22:22:51 +03:00
|
|
|
set -p _tide_pwd_output $colorDirs{$tide_pwd_unwritable_icon}
|
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
|
2020-06-07 23:52:35 +03:00
|
|
|
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-06-06 20:40:14 +03:00
|
|
|
else
|
2020-06-06 21:57:43 +03:00
|
|
|
if test (string length $truncatedPwd) -gt $_tide_pwd_max_length
|
2020-06-07 19:40:42 +03:00
|
|
|
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-06-07 19:40:42 +03:00
|
|
|
set -a truncatedList $dirTruncated
|
2020-06-06 20:40:14 +03:00
|
|
|
|
|
|
|
set truncatedPwd (string replace $dir $dirTruncated $truncatedPwd)
|
2020-06-08 06:14:15 +03:00
|
|
|
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
|
|
|
|
end
|
|
|
|
|
2020-06-23 02:18:51 +03:00
|
|
|
set _tide_pwd_output (string replace -a '/' $colorDirs'/' $_tide_pwd_output)
|
2020-06-06 20:40:14 +03:00
|
|
|
end
|