mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Fix bug in completions for the cd builtin that caused missed completions when using relative search paths and CDPATH. Also move the completions function to it's own file.
darcs-hash:20060709235518-ac50b-36c59205edbecd5c8967d8784fd43e46729c3cdc.gz
This commit is contained in:
parent
ac40a3bcd0
commit
ba9fbc67da
2 changed files with 43 additions and 37 deletions
|
@ -1,39 +1,2 @@
|
||||||
|
|
||||||
function __fish_complete_cd -d "Completions for the cd command"
|
|
||||||
|
|
||||||
#
|
|
||||||
# We can't simply use __fish_complete_directory because of the CDPATH
|
|
||||||
#
|
|
||||||
|
|
||||||
set -- wd $PWD
|
|
||||||
set -- owd $OLDPWD
|
|
||||||
|
|
||||||
# Check if CDPATH is set
|
|
||||||
|
|
||||||
set -l mycdpath
|
|
||||||
|
|
||||||
if test -z $CDPATH[1]
|
|
||||||
set mycdpath .
|
|
||||||
else
|
|
||||||
set mycdpath $CDPATH
|
|
||||||
end
|
|
||||||
|
|
||||||
if echo (commandline -ct)|grep '^/\|./' >/dev/null
|
|
||||||
# This is an absolute search path
|
|
||||||
eval printf '\%s\\tDirectory\\n' (commandline -ct)\*/
|
|
||||||
else
|
|
||||||
# This is a relative search path
|
|
||||||
# Iterate over every directory in CDPATH and check for possible completions
|
|
||||||
for i in $mycdpath
|
|
||||||
# Move to the initial directory first, in case the CDPATH directory is relative
|
|
||||||
builtin cd $wd
|
|
||||||
builtin cd $i
|
|
||||||
eval printf '"%s\tDirectory in "'$i'"\n"' (commandline -ct)\*/
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
builtin cd $wd
|
|
||||||
set -- OLDPWD $owd
|
|
||||||
end
|
|
||||||
|
|
||||||
complete -x -c cd -a "(__fish_complete_cd)"
|
complete -x -c cd -a "(__fish_complete_cd)"
|
||||||
|
|
43
share/functions/__fish_complete_cd.fish
Normal file
43
share/functions/__fish_complete_cd.fish
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
function __fish_complete_cd -d "Completions for the cd command"
|
||||||
|
|
||||||
|
#
|
||||||
|
# We can't simply use __fish_complete_directory because of the CDPATH
|
||||||
|
#
|
||||||
|
|
||||||
|
set -l wd $PWD
|
||||||
|
set -l owd $OLDPWD
|
||||||
|
|
||||||
|
# Check if CDPATH is set
|
||||||
|
|
||||||
|
set -l mycdpath
|
||||||
|
|
||||||
|
if test -z $CDPATH[1]
|
||||||
|
set mycdpath .
|
||||||
|
else
|
||||||
|
set mycdpath $CDPATH
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if echo (commandline -ct)|grep '^/\|^\./\|^\.\./' >/dev/null
|
||||||
|
# This is an absolute search path
|
||||||
|
eval printf '\%s\\tDirectory\\n' (commandline -ct)\*/
|
||||||
|
else
|
||||||
|
# This is a relative search path
|
||||||
|
# Iterate over every directory in CDPATH
|
||||||
|
# and check for possible completions
|
||||||
|
|
||||||
|
for i in $mycdpath
|
||||||
|
# Move to the initial directory first,
|
||||||
|
# in case the CDPATH directory is relative
|
||||||
|
|
||||||
|
builtin cd $wd
|
||||||
|
builtin cd $i
|
||||||
|
|
||||||
|
eval printf '"%s\tDirectory in "'$i'"\n"' (commandline -ct)\*/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
builtin cd $wd
|
||||||
|
set OLDPWD $owd
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue