From cd283bb36e0513eec511f898777c45b99de5f9bb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:25:18 +1300 Subject: Correct completion quoting for eds(1df) --- bash/bash_completion.d/eds.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/bash_completion.d/eds.bash b/bash/bash_completion.d/eds.bash index 371962ca..c6bff655 100644 --- a/bash/bash_completion.d/eds.bash +++ b/bash/bash_completion.d/eds.bash @@ -26,8 +26,8 @@ _eds() { ! [[ -d $file ]] || continue # Skip non-executable files [[ -x $file ]] || continue - # Print entry, null-terminated - printf '%q\0' "${file##*/}" + # Print quoted entry, slash-terminated + printf '%q/' "${file##*/}" done ) } -- cgit v1.2.3 From 62cf36d3521c282c957f8667e702886472e95a0f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:50:52 +1300 Subject: Correct find(1) completion to subshell exit --- bash/bash_completion.d/find.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash_completion.d/find.bash b/bash/bash_completion.d/find.bash index f87029e7..893cb0bc 100644 --- a/bash/bash_completion.d/find.bash +++ b/bash/bash_completion.d/find.bash @@ -31,7 +31,7 @@ _find() { -user -xdev ' -- "$2" - return + exit ;; esac -- cgit v1.2.3 From 743523eb8e882a5f7452f94a6f49340a948b1105 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:51:17 +1300 Subject: Add some comments to keep() completion --- bash/bash_completion.d/keep.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bash/bash_completion.d/keep.bash b/bash/bash_completion.d/keep.bash index c7144684..4b479eca 100644 --- a/bash/bash_completion.d/keep.bash +++ b/bash/bash_completion.d/keep.bash @@ -46,9 +46,13 @@ _keep() { # Build list of kept names bashkeep=${BASHKEEP:-"$HOME"/.bashkeep.d} for keep in "$bashkeep"/"$2"*.bash ; do + # Skip directories ! [[ -d $keep ]] || continue + # Strip leading path keep=${keep##*/} + # Strip trailing extension keep=${keep%.bash} + # Print kept name printf '%s\n' "$keep" done ;; -- cgit v1.2.3 From 8bb89092398dcc506df2da23b2ef73892d54d783 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:51:28 +1300 Subject: Reorder pattern filters for Makefile lines --- bash/bash_completion.d/make.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/bash_completion.d/make.bash b/bash/bash_completion.d/make.bash index 2527d145..567a2ec0 100644 --- a/bash/bash_completion.d/make.bash +++ b/bash/bash_completion.d/make.bash @@ -23,10 +23,10 @@ _make() { # Match expected format case $line in - # Has no equals sign anywhere - (*=*) continue ;; # First char not a tab ($'\t'*) continue ;; + # Has no equals sign anywhere + (*=*) continue ;; # Has a colon on the line (*:*) ;; # Skip anything else -- cgit v1.2.3 From 0516a03d3e635c7a7066f1ce9649d95210c4a8ec Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:51:41 +1300 Subject: Remove unneeded `local` declaration --- bash/bash_completion.d/make.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/bash/bash_completion.d/make.bash b/bash/bash_completion.d/make.bash index 567a2ec0..a077dc91 100644 --- a/bash/bash_completion.d/make.bash +++ b/bash/bash_completion.d/make.bash @@ -47,7 +47,6 @@ _make() { fi # Examine each target for completion suitability - local target for target in "${targets[@]}" ; do case $target in # Not .PHONY, .POSIX etc -- cgit v1.2.3 From f7e84eaccac42f57e6781f235edbe639a2f2b70e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:51:54 +1300 Subject: Make `sec` a local var in man page completion --- bash/bash_completion.d/man.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash index 274f663a..31be9a95 100644 --- a/bash/bash_completion.d/man.bash +++ b/bash/bash_completion.d/man.bash @@ -8,6 +8,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 -- cgit v1.2.3 From 7464165197bbd1fd43a24c84ef3f94cadcdd4be7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:52:21 +1300 Subject: Update glob settings for manual page completion --- bash/bash_completion.d/man.bash | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash index 31be9a95..4326c48a 100644 --- a/bash/bash_completion.d/man.bash +++ b/bash/bash_completion.d/man.bash @@ -24,20 +24,12 @@ _man() { 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 -- cgit v1.2.3 From 0ec77f392127d87bc2dad567c60fbd31f276a161 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:53:05 +1300 Subject: Adjust quoting and termination for man completion --- bash/bash_completion.d/man.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash index 4326c48a..7ee301d6 100644 --- a/bash/bash_completion.d/man.bash +++ b/bash/bash_completion.d/man.bash @@ -20,7 +20,7 @@ _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 < <( @@ -77,8 +77,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 -- cgit v1.2.3 From 2f5ccdcd1320ed01b212b0a862190cd0a0604422 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:53:16 +1300 Subject: Correct manpath(1) command in man completion I added the "a" as a quick-and-dirty test for the fallback condition below it, and accidentally committed it in 7d6fe8b. --- bash/bash_completion.d/man.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash index 7ee301d6..f8616029 100644 --- a/bash/bash_completion.d/man.bash +++ b/bash/bash_completion.d/man.bash @@ -32,7 +32,7 @@ _man() { 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 \ -- cgit v1.2.3 From 74966383e71fdb4c8abbbee1da68b5099ff9f6d6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 21:55:39 +1300 Subject: Trim some trailing whitespace --- bash/bash_completion.d/_completion_ignore_case.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash_completion.d/_completion_ignore_case.bash b/bash/bash_completion.d/_completion_ignore_case.bash index fe8208fc..b2bc3727 100644 --- a/bash/bash_completion.d/_completion_ignore_case.bash +++ b/bash/bash_completion.d/_completion_ignore_case.bash @@ -6,7 +6,7 @@ _completion_ignore_case() { [[ $set == 'completion-ignore-case on' ]] || continue return 0 done < <(bind -v) - + # Didn't find it, stay case-sensitive return 1 } -- cgit v1.2.3 From 9a489cf07642ffb1a3c3b5064601a471553ad768 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 22:02:31 +1300 Subject: Remove unneeded local var --- bash/bash_completion.d/make.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash_completion.d/make.bash b/bash/bash_completion.d/make.bash index a077dc91..7f8b8125 100644 --- a/bash/bash_completion.d/make.bash +++ b/bash/bash_completion.d/make.bash @@ -34,7 +34,7 @@ _make() { esac # Break the target up with space delimiters - local -a targets + declare -a targets IFS=' ' read -a targets -r \ < <(printf '%s\n' "${line%%:*}") -- cgit v1.2.3 From 60ea3c415a721ed99a254938b28c3e9356357b10 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 22:04:55 +1300 Subject: Add missing source of helper func to man complete --- bash/bash_completion.d/man.bash | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash index f8616029..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() { -- cgit v1.2.3 From c8a6cba61697c02ecc2e3c5db27629630d9fade2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 22:15:59 +1300 Subject: Move error increment to outside of if block --- bash/bashrc.d/keep.bash | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bash/bashrc.d/keep.bash b/bash/bashrc.d/keep.bash index a39d2fa7..2eebdae3 100644 --- a/bash/bashrc.d/keep.bash +++ b/bash/bashrc.d/keep.bash @@ -101,19 +101,17 @@ EOF # If -d was given, delete the keep files for the NAME if ((delete)) ; then - rm -- "$bashkeep"/"$name".bash || - ((errors++)) + rm -- "$bashkeep"/"$name".bash # Save a function elif [[ $(type -t "$name") = 'function' ]] ; then - declare -f -- "$name" >"$bashkeep"/"$name".bash || - ((errors++)) + declare -f -- "$name" >"$bashkeep"/"$name".bash # Save a variable elif declare -p -- "$name" >/dev/null ; then - declare -p -- "$name" >"$bashkeep"/"$name".bash || - ((errors++)) - fi + declare -p -- "$name" >"$bashkeep"/"$name".bash + + fi || ((errors++)) ;; esac done -- cgit v1.2.3 From 8d2670642c6de689948257bcdd7097e53ced83cb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 22:16:25 +1300 Subject: Use simple loop rather than glob tricks in keep --- bash/bashrc.d/keep.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bash/bashrc.d/keep.bash b/bash/bashrc.d/keep.bash index 2eebdae3..48196aeb 100644 --- a/bash/bashrc.d/keep.bash +++ b/bash/bashrc.d/keep.bash @@ -130,12 +130,12 @@ EOF # Otherwise the user must want us to print all the NAMEs kept ( shopt -s nullglob - declare -a keeps - keeps=("$bashkeep"/*.bash) - keeps=("${keeps[@]##*/}") - keeps=("${keeps[@]%.bash}") - ((${#keeps[@]})) || exit 0 - printf '%s\n' "${keeps[@]}" + for keep in "$bashkeep"/*.bash ; do + ! [[ -d $keep ]] || continue + keep=${keep##*/} + keep=${keep%.bash} + printf '%s\n' "$keep" + done ) } -- cgit v1.2.3 From b1c7a194e1c4a44da11ca901fb814c3d8b365719 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 22:24:03 +1300 Subject: Use variable for node count, not expansion Cheaper (I think). --- bash/bash_completion.d/bd.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash_completion.d/bd.bash b/bash/bash_completion.d/bd.bash index 09134e6a..4dde0eac 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 -- cgit v1.2.3 From a047504ab46f7fcf84a0425a802ad34310ad021c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 22:26:43 +1300 Subject: Remove unneeded braces --- bash/bash_completion.d/sd.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/bash_completion.d/sd.bash b/bash/bash_completion.d/sd.bash index 66dea73b..a776fbe3 100644 --- a/bash/bash_completion.d/sd.bash +++ b/bash/bash_completion.d/sd.bash @@ -24,7 +24,7 @@ _sd() { sibling=${sibling#../} case $sibling in ("${PWD##*/}") ;; - (*) printf '%q/' "${sibling}" ;; + (*) printf '%q/' "$sibling" ;; esac done ) -- cgit v1.2.3 From f7b14abebc09ac9720c259c26b91b0640d2555a0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 23:10:23 +1300 Subject: Make bd() and sd() match quoted and unquoted words I suspect there's a more correct way to do this, but it's working well for the moment. --- bash/bash_completion.d/bd.bash | 16 ++++++++++++---- bash/bash_completion.d/sd.bash | 28 +++++++++++++++++++--------- 2 files changed, 31 insertions(+), 13 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 diff --git a/bash/bash_completion.d/sd.bash b/bash/bash_completion.d/sd.bash index a776fbe3..4dc72f31 100644 --- a/bash/bash_completion.d/sd.bash +++ b/bash/bash_completion.d/sd.bash @@ -15,18 +15,28 @@ _sd() { # Make globs expand appropriately shopt -s dotglob nullglob if _completion_ignore_case ; then - shopt -s nocaseglob + shopt -s nocasematch 2>/dev/null fi # Print matching sibling dirs that are not the current dir - for sibling in ../"$2"*/ ; do - sibling=${sibling%/} - sibling=${sibling#../} - case $sibling in - ("${PWD##*/}") ;; - (*) printf '%q/' "$sibling" ;; - esac + for sib in ../*/ ; do + # Strip leading ../ + sib=${sib#../} + # Strip trailing slash + sib=${sib%/} + # Skip self + [[ $sib != "${PWD##*/}" ]] || continue + # Check the quoted and unquoted word for matching + for match in "$sib" "$(printf '%q' "$sib")" ; do + # Print any match, slash-terminated + case $match in + ("$2"*) + printf '%s/' "$sib" + continue + ;; + esac + done done ) } -complete -F _sd sd +complete -F _sd -o filenames sd -- cgit v1.2.3 From 3aa53b7ef6cf18fa13c1a00c529f04656f0bf747 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 23:11:55 +1300 Subject: Use native filename quoting for td(1df) complete --- bash/bash_completion.d/eds.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/bash_completion.d/eds.bash b/bash/bash_completion.d/eds.bash index c6bff655..01db4129 100644 --- a/bash/bash_completion.d/eds.bash +++ b/bash/bash_completion.d/eds.bash @@ -27,8 +27,8 @@ _eds() { # Skip non-executable files [[ -x $file ]] || continue # Print quoted entry, slash-terminated - printf '%q/' "${file##*/}" + printf '%s/' "${file##*/}" done ) } -complete -F _eds eds +complete -F _eds -o filenames eds -- cgit v1.2.3 From ea88fca652d43e8582b8a0c981509db3a15bc725 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 23:12:15 +1300 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 1f343c3f..a5c7149a 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v2.7.0 -Sun Dec 2 05:03:14 UTC 2018 +tejr dotfiles v2.8.0 +Sun Dec 2 10:12:15 UTC 2018 -- cgit v1.2.3