Further optimize pwd truncation

This commit is contained in:
Ilan Cosman 2021-12-22 14:59:52 -08:00
parent 46587cb19b
commit 2d5474005c

View File

@ -27,9 +27,8 @@ function _tide_pwd
end end
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
trunc_len=1 while string match -qr "(?<trunc>.{$trunc_len})" $dir_section && set -l trunc
test (count $parent_dir/$trunc*/) != 1 while string match -qr "(?<trunc>$trunc.)" $dir_section && test (count $parent_dir/$trunc*/) != 1
math $trunc_len+1 | read trunc_len
end end
test -n "$trunc" && set split_output[$i] $_tide_color_truncated_dirs$trunc$_tide_reset_to_color_dirs && test -n "$trunc" && 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 string join / $split_output | string length --visible | read -g pwd_length