aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-10-21 13:55:39 +1300
committerTom Ryder <tom@sanctum.geek.nz>2015-10-21 13:55:39 +1300
commite8931dff60564306a5a6370f97d7c543e5663f1e (patch)
treee798e3c1085e4e788df2d8119141f407a7feaf24 /bash/bashrc.d
parentSwitch compopt back out (diff)
downloaddotfiles-e8931dff60564306a5a6370f97d7c543e5663f1e.tar.gz
dotfiles-e8931dff60564306a5a6370f97d7c543e5663f1e.zip
When expanding with globbing, use prefix
Rather than generating all possible completions and then filtering them down, use the completing word as a prefix for the glob
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r--bash/bashrc.d/mysql.bash3
-rw-r--r--bash/bashrc.d/pass.bash3
-rw-r--r--bash/bashrc.d/path.bash4
-rw-r--r--bash/bashrc.d/ud.bash3
4 files changed, 4 insertions, 9 deletions
diff --git a/bash/bashrc.d/mysql.bash b/bash/bashrc.d/mysql.bash
index 67feca3c..2faa4e81 100644
--- a/bash/bashrc.d/mysql.bash
+++ b/bash/bashrc.d/mysql.bash
@@ -35,7 +35,6 @@ _mysql() {
# Return the names of the .cnf files sans prefix as completions
local db
while IFS= read -d '' -r db ; do
- [[ $db == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
COMPREPLY=("${COMPREPLY[@]}" "$db")
done < <(
@@ -44,7 +43,7 @@ _mysql() {
# Collect all the config file names, strip off leading path and .cnf
local -a cnfs
- cnfs=("$dirname"/*.cnf)
+ cnfs=("$dirname"/"${COMP_WORDS[COMP_CWORD]}"*.cnf)
cnfs=("${cnfs[@]#$dirname/}")
cnfs=("${cnfs[@]%.cnf}")
diff --git a/bash/bashrc.d/pass.bash b/bash/bashrc.d/pass.bash
index e8748118..12539a17 100644
--- a/bash/bashrc.d/pass.bash
+++ b/bash/bashrc.d/pass.bash
@@ -15,7 +15,6 @@ _pass()
# doesn't seem to do this properly with a null delimiter)
local entry
while IFS= read -d '' -r entry ; do
- [[ $entry == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
# We have to use printf %q here to quote the entry, as it may include
# spaces or newlines, just like any filename
@@ -31,7 +30,7 @@ _pass()
# Gather the entries and remove their .gpg suffix
declare -a entries
- entries=(**/*.gpg)
+ entries=("${COMP_WORDS[COMP_CWORD]}"*/**/*.gpg "${COMP_WORDS[COMP_CWORD]}"*.gpg)
entries=("${entries[@]%.gpg}")
# Bail if no entries to prevent empty output
diff --git a/bash/bashrc.d/path.bash b/bash/bashrc.d/path.bash
index bd290fb3..fb91558b 100644
--- a/bash/bashrc.d/path.bash
+++ b/bash/bashrc.d/path.bash
@@ -199,8 +199,6 @@ _path() {
insert|i|append|add|a|check|c|set|s)
local dirname
while IFS= read -d '' -r dirname ; do
- [[ $dirname == "${COMP_WORDS[COMP_CWORD]}"/* ]] \
- || continue
COMPREPLY=("${COMPREPLY[@]}" "$dirname")
done < <(
@@ -209,7 +207,7 @@ _path() {
# Collect directory names, strip trailing slash
local -a dirnames
- dirnames=(*/)
+ dirnames=("${COMP_WORDS[COMP_CWORD]}"*/)
dirnames=("${dirnames[@]%/}")
# Bail if no results to prevent empty output
diff --git a/bash/bashrc.d/ud.bash b/bash/bashrc.d/ud.bash
index 46dbdd71..b05539ab 100644
--- a/bash/bashrc.d/ud.bash
+++ b/bash/bashrc.d/ud.bash
@@ -58,7 +58,6 @@ _ud() {
# Iterate through directories, null-separated, add them to completions
local dirname
while IFS= read -d '' -r dirname ; do
- [[ $dirname == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
COMPREPLY=("${COMPREPLY[@]}" "$dirname")
done < <(
@@ -67,7 +66,7 @@ _ud() {
# Collect directory names, strip trailing slashes
local -a dirnames
- dirnames=(*/)
+ dirnames=("${COMP_WORDS[COMP_CWORD]}"*/)
dirnames=("${dirnames[@]%/}")
# Bail if no results to prevent empty output