tide/conf.d/_tide_pwd.fish

27 lines
1.1 KiB
Fish
Raw Normal View History

2020-06-06 20:40:14 +03:00
function _tide_pwd
set -l truncatedPwd $_tide_pwd
2020-06-06 21:57:43 +03:00
set -g _tide_pwd_output $_tide_pwd
2020-06-06 20:40:14 +03:00
if not test -w $PWD
2020-06-06 21:57:43 +03:00
set _tide_pwd_output $_tide_pwd_dir_color{$tide_pwd_unwritable_icon}' '$_tide_pwd_output
2020-06-06 20:40:14 +03:00
end
for dir in $_tide_split_pwd
set -l index (contains -i $dir $_tide_split_pwd)
2020-06-06 21:57:43 +03:00
if contains $index $_tide_pwd_anchors
set _tide_pwd_output (string replace $dir "$_tide_pwd_anchor_color"$dir(set_color normal) $_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-06 20:40:14 +03:00
set -l dirTruncated (string sub -l 1 $dir)
if test $dirTruncated = '.'
set dirTruncated (string sub -l 2 $dir)
end
set truncatedPwd (string replace $dir $dirTruncated $truncatedPwd)
2020-06-06 21:57:43 +03:00
set _tide_pwd_output (string replace $dir "$_tide_pwd_truncated_dir_color"$dirTruncated $_tide_pwd_output)
2020-06-06 20:40:14 +03:00
end
end
end
2020-06-06 21:57:43 +03:00
set _tide_pwd_output (string replace -a '/' "$_tide_pwd_dir_color"'/' $_tide_pwd_output)
2020-06-06 20:40:14 +03:00
end