mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
completions/cdh: Only shorten ~ if the token starts with one
Works around #4570 Also keep order like it always wanted. [ci skip]
This commit is contained in:
parent
6aed132224
commit
0259b29a09
1 changed files with 11 additions and 4 deletions
|
@ -11,13 +11,20 @@ function __fish_cdh_args
|
|||
end
|
||||
end
|
||||
|
||||
# Only shorten $HOME to "~" if the token starts with a "~",
|
||||
# otherwise fish will escape it.
|
||||
set -l shorten_tilde 0
|
||||
string match -q '~*' -- (commandline -ct); and set shorten_tilde 1
|
||||
|
||||
for dir in $uniq_dirs
|
||||
if test $shorten_tilde -eq 1
|
||||
set -l home_dir (string match -r "$HOME(/.*|\$)" "$dir")
|
||||
if set -q home_dir[2]
|
||||
set dir "~$home_dir[2]"
|
||||
end
|
||||
end
|
||||
echo $dir
|
||||
end
|
||||
end
|
||||
|
||||
complete -c cdh -xa '(__fish_cdh_args)'
|
||||
complete -c cdh -kxa '(__fish_cdh_args)'
|
||||
|
|
Loading…
Reference in a new issue