Don't anchor the first directory

This commit is contained in:
Ilan Cosman 2022-05-06 13:33:32 -07:00
parent 32e4b8dcf8
commit d5cc473304
2 changed files with 3 additions and 6 deletions

View File

@ -98,7 +98,7 @@ The current working directory is the most important part of any shell prompt. Ti
![pwd][]
When the full directory doesn't fit, the leftmost segment is truncated to its shortest unique prefix. In the example above, `Documents` becomes `Doc` instead of `D` because that could be confused with `Downloads`. Important segments are bold and never truncated. These include the first and the last segments, roots of Git repositories etc.
When the full directory doesn't fit, the leftmost segment is truncated to its shortest unique prefix. In the example above, `Documents` becomes `Doc` instead of `D` because that could be confused with `Downloads`. Important segments are bold and never truncated. These include the last segment, root of a Git repository etc.
<sup>_Tip_: If you copy-paste a truncated path and hit <kbd>tab</kbd>, it will complete to the original.</sup>

View File

@ -13,10 +13,7 @@ eval "function _tide_pwd
set -f icon $home_icon
end
# Anchor first and last directories (which may be the same)
test -n \"\$split_pwd[1]\" && # ~/foo/bar, hightlight ~ OR /foo/bar, hightlight foo not empty string
set -l split_output \"$reset_to_color_dirs\$icon$color_anchors\$split_pwd[1]$reset_to_color_dirs\" \$split_pwd[2..] ||
set -l split_output \"$reset_to_color_dirs\$icon\" \"$color_anchors\$split_pwd[2]$reset_to_color_dirs\" \$split_pwd[3..]
set -l split_output \"\$icon\$split_pwd[1]\" \$split_pwd[2..]
set split_output[-1] \"$color_anchors\$split_output[-1]$reset_to_color_dirs\"
string join / \$split_output | string length -V | read -g _tide_pwd_len
@ -39,5 +36,5 @@ eval "function _tide_pwd
end
end
string join -- / \$split_output
string join -- / \"$reset_to_color_dirs\$split_output[1]\" \$split_output[2..]
end"