mirror of
https://github.com/IlanCosman/tide.git
synced 2024-12-22 19:41:36 +03:00
Speed up pwd truncation algorithm
This commit is contained in:
parent
e56e1f971c
commit
e41aeecf9b
@ -27,12 +27,11 @@ function _tide_pwd
|
||||
end
|
||||
set split_output[$i] $_tide_color_anchors$dir_section$_tide_reset_to_color_dirs
|
||||
else if test $pwd_length -gt $dist_btwn_sides
|
||||
string sub --length 1 -- $dir_section | read -l trunc
|
||||
trunc_len=1 while test $trunc != $dir_section -a (count $parent_dir/$trunc*/) != 1
|
||||
trunc_len=1 while string match -qr "(?<trunc>.{$trunc_len})" $dir_section &&
|
||||
test (count $parent_dir/$trunc*/) != 1
|
||||
math $trunc_len+1 | read trunc_len
|
||||
string sub --length $trunc_len -- $dir_section | read trunc
|
||||
end
|
||||
if test $trunc != $dir_section
|
||||
if 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
|
||||
end
|
||||
|
@ -49,6 +49,11 @@ mkdir -p $tmpdir/alfa/bratwurst
|
||||
_pwd "$longDir" # CHECK: ~/a/brav/c/d/e/f/golf/hotel/india/juliett/kilo/lima/mike/november/oscar/papa
|
||||
rm -r $tmpdir/alfa/bratwurst
|
||||
|
||||
# Truncate to unique
|
||||
mkdir -p $tmpdir/alfa/bravohello
|
||||
_pwd "$longDir" # CHECK: ~/a/bravo/c/d/e/f/golf/hotel/india/juliett/kilo/lima/mike/november/oscar/papa
|
||||
rm -r $tmpdir/alfa/bravohello
|
||||
|
||||
# Markers
|
||||
mkdir -p $tmpdir/alfa/.git
|
||||
_pwd "$longDir" # CHECK: ~/alfa/b/c/d/e/f/golf/hotel/india/juliett/kilo/lima/mike/november/oscar/papa
|
||||
|
Loading…
Reference in New Issue
Block a user