diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2014-02-14 20:42:41 +0100 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2014-02-14 20:42:41 +0100 |
commit | eda90cf473d2060f3cd727b2685bc700a1353a29 (patch) | |
tree | 37c986063078ef714b4e6e271375c857947a2dd9 | |
parent | 3020ea9939195b044b69382eab7c2a3ab6360b05 (diff) | |
download | dotfiles-eda90cf473d2060f3cd727b2685bc700a1353a29.tar.gz dotfiles-eda90cf473d2060f3cd727b2685bc700a1353a29.tar.xz dotfiles-eda90cf473d2060f3cd727b2685bc700a1353a29.zip |
Bash config: further enhance diralias bash completion
- avoid completion of empty string (standing for the actual directory
itself)
- prevent multiple completions as only one argument makes sense
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r-- | .bashrc | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -14,8 +14,10 @@ diralias () { # so this way, albeit complicated, convenient traversal is achieved # XXX could -G be used instead? complete -o nospace -C \ - "f(){ find \"${1%%* }/\${2%\${2##*/}}\" -maxdepth 1 -type d -name \"\${2##*/}*\" \ - -printf \"\${2%\${2##*/}}%P\\n\"; }; f" "$(basename "$1")" + "f(){ test \"\$3\" != \"$(basename "$1")\" || \ + find \"${1%%* }/\${2%\${2##*/}}\" -mindepth 1 -maxdepth 1 -type d \ + -name \"\${2##*/}*\" -printf \"\${2%\${2##*/}}%P\\n\"; }; f" \ + "$(basename "$1")" } _linkalias () { |