aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/bd.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bash_completion.d/bd.bash')
-rw-r--r--bash/bash_completion.d/bd.bash13
1 files changed, 8 insertions, 5 deletions
diff --git a/bash/bash_completion.d/bd.bash b/bash/bash_completion.d/bd.bash
index 86146a4e..e67cdd09 100644
--- a/bash/bash_completion.d/bd.bash
+++ b/bash/bash_completion.d/bd.bash
@@ -2,21 +2,24 @@
_bd() {
# Only makes sense for the first argument
- ((COMP_CWORD == 1)) || return 1
+ ((COMP_CWORD == 1)) || return
# Build a list of dirnames in $PWD
local -a dirnames
IFS=/ read -rd '' -a dirnames < <(printf '%s\0' "${PWD#/}")
# Remove the last element in the array (the current directory)
- ((${#dirnames[@]})) || return 1
- dirnames=("${dirnames[@]:0:$((${#dirnames[@]}-1))}")
+ ((${#dirnames[@]})) || return
+ dirnames=("${dirnames[@]:0:${#dirnames[@]}-1}")
# Add the matching dirnames to the reply
local dirname
for dirname in "${dirnames[@]}" ; do
- [[ $dirname == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
- COMPREPLY[${#COMPREPLY[@]}]=$(printf %q "$dirname")
+ case $dirname in
+ "${COMP_WORDS[COMP_CWORD]}"*)
+ COMPREPLY[${#COMPREPLY[@]}]=$(printf %q "$dirname")
+ ;;
+ esac
done
}
complete -F _bd bd