aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/man.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/man.bash
parentMerge branch 'release/v2.7.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-456ccb394342528e1d3a8e17277a51039c9c2549.tar.gz
dotfiles-456ccb394342528e1d3a8e17277a51039c9c2549.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/man.bash')
-rw-r--r--bash/bash_completion.d/man.bash30
1 files changed, 14 insertions, 16 deletions
diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash
index 274f663a..50ab852e 100644
--- a/bash/bash_completion.d/man.bash
+++ b/bash/bash_completion.d/man.bash
@@ -1,3 +1,8 @@
+# Load _completion_ignore_case helper function
+if ! declare -F _completion_ignore_case >/dev/null ; then
+ source "$HOME"/.bash_completion.d/_completion_ignore_case.bash
+fi
+
# Autocompletion for man(1)
_man() {
@@ -8,6 +13,7 @@ _man() {
# If previous word started with a number, we'll assume that's a section to
# search
+ local sec
case $3 in
[0-9]*) sec=$3 ;;
esac
@@ -19,27 +25,19 @@ _man() {
# Read completion results from a subshell and add them to the COMPREPLY
# array individually
local ci comp
- while IFS= read -d '' -r comp ; do
+ while IFS= read -d / -r comp ; do
COMPREPLY[ci++]=$comp
done < <(
- # Do not return dotfiles, give us extended globbing, and expand empty
- # globs to just nothing
+ # Make globs expand appropriately
shopt -u dotglob
shopt -s nullglob
-
- # Make globbing case-insensitive if appropriate
- while read -r _ setting ; do
- case $setting in
- ('completion-ignore-case on')
- shopt -s nocaseglob
- break
- ;;
- esac
- done < <(bind -v)
+ if _completion_ignore_case ; then
+ shopt -s nocaseglob
+ fi
# Figure out the manual paths to search
- if hash amanpath 2>/dev/null ; then
+ if hash manpath 2>/dev/null ; then
# manpath(1) exists, run it to find what to search
IFS=: read -a manpaths -r \
@@ -84,8 +82,8 @@ _man() {
# Strip section suffixes
pages=("${pages[@]%.[0-9]*}")
- # Print entries, null-delimited
- printf '%s\0' "${pages[@]}"
+ # Print quoted entries, slash-delimited
+ printf '%q/' "${pages[@]}"
)
}
complete -F _man -o bashdefault -o default man