2022-01-15 19:25:15 +03:00
|
|
|
set_color -o $tide_pwd_color_anchors | read -l color_anchors
|
|
|
|
set_color $tide_pwd_color_truncated_dirs | read -l color_truncated
|
|
|
|
set -l reset_to_color_dirs (set_color normal -b $tide_pwd_bg_color; set_color $tide_pwd_color_dirs)
|
2021-05-30 03:11:46 +03:00
|
|
|
|
2022-05-06 23:43:22 +03:00
|
|
|
set -l unwritable_icon $tide_pwd_icon_unwritable' '
|
|
|
|
set -l home_icon $tide_pwd_icon_home' '
|
|
|
|
set -l pwd_icon $tide_pwd_icon' '
|
2022-01-05 22:25:32 +03:00
|
|
|
|
|
|
|
eval "function _tide_pwd
|
2022-01-19 19:24:38 +03:00
|
|
|
if set -l split_pwd (string replace -r '^$HOME' '~' \$PWD | string split /)
|
2022-05-06 23:43:22 +03:00
|
|
|
test -w . && set -f split_output \"$pwd_icon\$split_pwd[1]\" \$split_pwd[2..] ||
|
|
|
|
set -f split_output \"$unwritable_icon\$split_pwd[1]\" \$split_pwd[2..]
|
2022-05-07 03:34:16 +03:00
|
|
|
set split_output[-1] \"$color_anchors\$split_output[-1]$reset_to_color_dirs\"
|
2021-07-22 20:01:50 +03:00
|
|
|
else
|
2022-05-07 03:34:16 +03:00
|
|
|
set -f split_output \"$home_icon$color_anchors~\"
|
2021-05-30 03:11:46 +03:00
|
|
|
end
|
2021-08-26 23:47:43 +03:00
|
|
|
|
2022-01-26 20:35:35 +03:00
|
|
|
string join / \$split_output | string length -V | read -g _tide_pwd_len
|
2021-06-02 02:34:42 +03:00
|
|
|
|
2022-01-05 22:25:32 +03:00
|
|
|
i=1 for dir_section in \$split_pwd[2..-2]
|
|
|
|
string join -- / \$split_pwd[..\$i] | string replace '~' $HOME | read -l parent_dir # Uses i before increment
|
2021-05-30 03:11:46 +03:00
|
|
|
|
2022-01-05 22:25:32 +03:00
|
|
|
math \$i+1 | read i
|
2021-01-16 04:33:49 +03:00
|
|
|
|
2021-11-25 21:51:31 +03:00
|
|
|
if false || for marker in $tide_pwd_markers # false is for if tide_pwd_markers is empty
|
2022-01-05 22:25:32 +03:00
|
|
|
test -e \$parent_dir/\$dir_section/\$marker && break
|
2021-11-25 21:08:41 +03:00
|
|
|
end
|
2022-01-06 00:50:08 +03:00
|
|
|
set split_output[\$i] \"$color_anchors\$dir_section$reset_to_color_dirs\"
|
2022-01-26 20:35:35 +03:00
|
|
|
else if test \$_tide_pwd_len -gt \$dist_btwn_sides
|
2021-12-23 01:59:52 +03:00
|
|
|
set -l trunc
|
2022-05-30 19:43:30 +03:00
|
|
|
while string match -qr \"(?<trunc>\$trunc.)\" \$dir_section && v=\$parent_dir/\$trunc*/ set -q v[2]
|
2021-11-05 00:26:53 +03:00
|
|
|
end
|
2022-01-06 00:50:08 +03:00
|
|
|
test -n \"\$trunc\" && set split_output[\$i] \"$color_truncated\$trunc$reset_to_color_dirs\" &&
|
2022-01-26 20:35:35 +03:00
|
|
|
string join / \$split_output | string length -V | read _tide_pwd_len
|
2020-11-24 01:56:52 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-05-06 23:33:32 +03:00
|
|
|
string join -- / \"$reset_to_color_dirs\$split_output[1]\" \$split_output[2..]
|
2022-01-05 22:25:32 +03:00
|
|
|
end"
|