Minor refactor of pwd

This commit is contained in:
Ilan Cosman 2021-11-04 14:26:53 -07:00
parent 2dccfe9c6e
commit 28e1a8fa48

View File

@ -26,14 +26,14 @@ function _tide_pwd
if test -z false (string split --max 2 " " -- "-o -e $parent_dir/$dir_section/"$tide_pwd_markers) if test -z false (string split --max 2 " " -- "-o -e $parent_dir/$dir_section/"$tide_pwd_markers)
set split_output[$i] $_tide_color_anchors$dir_section$_tide_reset_to_color_dirs set split_output[$i] $_tide_color_anchors$dir_section$_tide_reset_to_color_dirs
else if test $pwd_length -gt $dist_btwn_sides else if test $pwd_length -gt $dist_btwn_sides
while math $truncation_length +1 | read -l truncation_length && string sub --length 1 -- $dir_section | read -l trunc
string sub --length $truncation_length -- $dir_section | read -l truncated && trunc_len=1 while test $trunc != $dir_section -a (count $parent_dir/$trunc*/) != 1
test $truncated != $dir_section math $trunc_len+1 | read trunc_len
if test (count $parent_dir/$truncated*/) = 1 string sub --length $trunc_len -- $dir_section | read trunc
set split_output[$i] $_tide_color_truncated_dirs$truncated$_tide_reset_to_color_dirs
string join / $split_output | string length --visible | read -g pwd_length
break
end end
if test $trunc != $dir_section
set split_output[$i] $_tide_color_truncated_dirs$trunc$_tide_reset_to_color_dirs
string join / $split_output | string length --visible | read -g pwd_length
end end
end end
end end