aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/bd.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-02 23:12:15 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-02 23:12:15 +1300
commit456ccb394342528e1d3a8e17277a51039c9c2549 (patch)
tree7d85c2282553762caa50c6d675c97709d51d2c2b /bash/bash_completion.d/bd.bash
parentMerge branch 'release/v2.7.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-2.8.0.tar.gz (sig)
dotfiles-2.8.0.zip
Merge branch 'release/v2.8.0'v2.8.0
* release/v2.8.0: Bump VERSION Use native filename quoting for td(1df) complete Make bd() and sd() match quoted and unquoted words Remove unneeded braces Use variable for node count, not expansion Use simple loop rather than glob tricks in keep Move error increment to outside of if block Add missing source of helper func to man complete Remove unneeded local var Trim some trailing whitespace Correct manpath(1) command in man completion Adjust quoting and termination for man completion Update glob settings for manual page completion Make `sec` a local var in man page completion Remove unneeded `local` declaration Reorder pattern filters for Makefile lines Add some comments to keep() completion Correct find(1) completion to subshell exit Correct completion quoting for eds(1df)
Diffstat (limited to 'bash/bash_completion.d/bd.bash')
-rw-r--r--bash/bash_completion.d/bd.bash18
1 files changed, 13 insertions, 5 deletions
diff --git a/bash/bash_completion.d/bd.bash b/bash/bash_completion.d/bd.bash
index 09134e6a..32969522 100644
--- a/bash/bash_completion.d/bd.bash
+++ b/bash/bash_completion.d/bd.bash
@@ -22,7 +22,7 @@ _bd() {
done
# Continue if we have at least two nodes, counting the leaf
- ((${#nodes[@]} > 1)) || return
+ ((ni > 1)) || return
# Shift off the leaf, since it is not meaningful to go "back to" the
# current directory
@@ -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