mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 21:18:53 +00:00
Fix cd completions if a directory exists in $CDPATH and $PWD
E.g. if "foo" is in CDPATH, and both "foo/bar" and "./bar" exist, `cd bar` will go to ./bar. The completions described "bar" as going to "foo/bar" ("CDPATH foo"). This fixes it by checking for ./bar's existence. See #4475.
This commit is contained in:
parent
0a1294758d
commit
1af38d69a8
1 changed files with 6 additions and 1 deletions
|
@ -30,9 +30,14 @@ function __fish_complete_cd -d "Completions for the cd command"
|
||||||
set -l desc (string replace -r -- "^$HOME" "~" "$cdpath")
|
set -l desc (string replace -r -- "^$HOME" "~" "$cdpath")
|
||||||
# This assumes the CDPATH component itself is cd-able.
|
# This assumes the CDPATH component itself is cd-able.
|
||||||
for d in $cdpath/$token*/
|
for d in $cdpath/$token*/
|
||||||
|
set -l withoutcdpath (string replace -- "$cdpath/" "" $d)
|
||||||
|
# Skip if the path exists in the current directory, since that's what `cd` will use.
|
||||||
|
if test -d "$withoutcdpath" -a -x "$withoutcdpath"
|
||||||
|
continue
|
||||||
|
end
|
||||||
# Remove the cdpath component again.
|
# Remove the cdpath component again.
|
||||||
test -x $d
|
test -x $d
|
||||||
and printf "%s\tCDPATH %s\n" (string replace -r "^$cdpath/" "" -- $d) $desc
|
and printf "%s\tCDPATH %s\n" "$withoutcdpath" $desc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue