mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
fix #177 (complete 'cd' only with paths)
This commit is contained in:
parent
9457c115be
commit
e995cc9329
@ -1,11 +1,8 @@
|
|||||||
function __fish_complete_cd -d "Completions for the cd command"
|
function __fish_complete_cd -d "Completions for the cd command"
|
||||||
|
|
||||||
#
|
#
|
||||||
# We can't simply use __fish_complete_directories because of the CDPATH
|
# We can't simply use __fish_complete_directories because of the CDPATH
|
||||||
#
|
#
|
||||||
|
|
||||||
set -l wd $PWD
|
set -l wd $PWD
|
||||||
set -l owd $OLDPWD
|
|
||||||
|
|
||||||
# Check if CDPATH is set
|
# Check if CDPATH is set
|
||||||
|
|
||||||
@ -17,10 +14,10 @@ function __fish_complete_cd -d "Completions for the cd command"
|
|||||||
set mycdpath $CDPATH
|
set mycdpath $CDPATH
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set -l ctoken (commandline -ct)
|
||||||
if echo '(commandline -ct)'|sgrep '^/\|^\./\|^\.\./' >/dev/null
|
if echo $ctoken | sgrep '^/\|^\./\|^\.\./\|^~/' >/dev/null
|
||||||
# This is an absolute search path
|
# This is an absolute search path
|
||||||
eval printf '\%s\\tDirectory\\n' '(commandline -ct)'\*/
|
eval printf '\%s\\tDirectory\\n' $ctoken\*/
|
||||||
else
|
else
|
||||||
# This is a relative search path
|
# This is a relative search path
|
||||||
# Iterate over every directory in CDPATH
|
# Iterate over every directory in CDPATH
|
||||||
@ -33,11 +30,10 @@ function __fish_complete_cd -d "Completions for the cd command"
|
|||||||
builtin cd $wd
|
builtin cd $wd
|
||||||
eval builtin cd $i
|
eval builtin cd $i
|
||||||
|
|
||||||
eval printf '"%s\tDirectory in "'$i'"\n"' '(commandline -ct)'\*/
|
eval printf '"%s\tDirectory in "'$i'"\n"' $ctoken\*/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
builtin cd $wd
|
builtin cd $wd
|
||||||
set OLDPWD $owd
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user