diff options
author | axel <axel@liljencrantz.se> | 2006-02-17 20:13:39 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-02-17 20:13:39 +1000 |
commit | 343cafef346543282b5b6e825bc8f9dd10028a48 (patch) | |
tree | 1bcf221ecb525c7aeadc8325e7b780d3656e544b /share/completions/cd.fish | |
parent | 95a01f3c8f15034433ffce368d8f2d13d925139c (diff) |
Redo installation file structure, move lots of things to $PREFIX/share/fish
darcs-hash:20060217101339-ac50b-d93d2c620a4b7f75f05ff461a6edbee001da7613.gz
Diffstat (limited to 'share/completions/cd.fish')
-rw-r--r-- | share/completions/cd.fish | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/share/completions/cd.fish b/share/completions/cd.fish new file mode 100644 index 00000000..93eadcb7 --- /dev/null +++ b/share/completions/cd.fish @@ -0,0 +1,39 @@ + +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)" |