From e8931dff60564306a5a6370f97d7c543e5663f1e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 21 Oct 2015 13:55:39 +1300 Subject: 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 --- bash/bashrc.d/mysql.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bash/bashrc.d/mysql.bash') 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}") -- cgit v1.2.3