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.bash16
1 files changed, 12 insertions, 4 deletions
diff --git a/bash/bash_completion.d/bd.bash b/bash/bash_completion.d/bd.bash
index 4dde0eac..32969522 100644
--- a/bash/bash_completion.d/bd.bash
+++ b/bash/bash_completion.d/bd.bash
@@ -36,10 +36,18 @@ _bd() {
# Iterate through the nodes and print the ones that match the word
# being completed, with a trailing slash as terminator
for node in "${nodes[@]}" ; do
- case $node in
- ("$2"*) printf '%s/' "$node" ;;
- esac
+ node_quoted=$(printf '%q' "$node")
+ # Check the quoted and unquoted word for matching
+ for match in "$node" "$(printf '%q' "$node")" ; do
+ # Print any match, slash-terminated
+ case $match in
+ ("$2"*)
+ printf '%s/' "$node"
+ continue
+ ;;
+ esac
+ done
done
)
}
-complete -F _bd bd
+complete -F _bd -o filenames bd