diff options
author | axel <axel@liljencrantz.se> | 2006-07-10 09:55:18 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-07-10 09:55:18 +1000 |
commit | ba9fbc67da7c4e7de8691b14066ec0d4c938f716 (patch) | |
tree | 57b9ef3fd02bd3f4ed9d6dbe17d071b81569ecfe /share/functions/__fish_complete_cd.fish | |
parent | ac40a3bcd0541f09e1ee5cb9aae2b951f0551304 (diff) |
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
Diffstat (limited to 'share/functions/__fish_complete_cd.fish')
-rw-r--r-- | share/functions/__fish_complete_cd.fish | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/share/functions/__fish_complete_cd.fish b/share/functions/__fish_complete_cd.fish new file mode 100644 index 00000000..f498f2a1 --- /dev/null +++ b/share/functions/__fish_complete_cd.fish @@ -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 + |