aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-10-30 10:31:53 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-10-30 10:31:53 +1300
commita8c7c927dcf3c020389fd25c3e81e6c072a25dd1 (patch)
treeb2eeffa04f868f4335de1bf4ce238754788d5db2 /bash
parentUse case statement for sudo -v switching (diff)
downloaddotfiles-a8c7c927dcf3c020389fd25c3e81e6c072a25dd1.tar.gz
dotfiles-a8c7c927dcf3c020389fd25c3e81e6c072a25dd1.zip
Respect completion-ignore-case in custom functions
This involves a little too much boilerplate for my liking, but it's still an improvement over what I had before. I might find a way to make this into a generic function.
Diffstat (limited to 'bash')
-rw-r--r--bash/bash_completion.d/eds.bash15
-rw-r--r--bash/bash_completion.d/keep.bash15
-rw-r--r--bash/bash_completion.d/man.bash14
-rw-r--r--bash/bash_completion.d/mysql.bash14
-rw-r--r--bash/bash_completion.d/pass.bash14
-rw-r--r--bash/bash_completion.d/path.bash14
-rw-r--r--bash/bash_completion.d/sd.bash14
-rw-r--r--bash/bash_completion.d/td.bash15
-rw-r--r--bash/bash_completion.d/ud.bash14
9 files changed, 129 insertions, 0 deletions
diff --git a/bash/bash_completion.d/eds.bash b/bash/bash_completion.d/eds.bash
index 58ecf402..c4a9b9a9 100644
--- a/bash/bash_completion.d/eds.bash
+++ b/bash/bash_completion.d/eds.bash
@@ -10,6 +10,21 @@ _eds() {
COMPREPLY[${#COMPREPLY[@]}]=$executable
done < <(
shopt -s dotglob nullglob
+
+ # Make globbing case-insensitive if appropriate; is there a cleaner way
+ # to find this value?
+ while read -r _ option value ; do
+ case $option in
+ completion-ignore-case)
+ case $value in
+ on)
+ shopt -s nocaseglob
+ break
+ ;;
+ esac
+ esac
+ done < <(bind -v)
+
declare -a files
files=("${EDSPATH:-"$HOME"/.local/bin}"/"${COMP_WORDS[COMP_CWORD]}"*)
declare -a executables
diff --git a/bash/bash_completion.d/keep.bash b/bash/bash_completion.d/keep.bash
index 7148ad2b..5958aaf5 100644
--- a/bash/bash_completion.d/keep.bash
+++ b/bash/bash_completion.d/keep.bash
@@ -39,6 +39,21 @@ _keep() {
COMPREPLY[${#COMPREPLY[@]}]=$word
done < <(
shopt -s dotglob nullglob
+
+ # Make globbing case-insensitive if appropriate; is there a cleaner way
+ # to find this value?
+ while read -r _ option value ; do
+ case $option in
+ completion-ignore-case)
+ case $value in
+ on)
+ shopt -s nocaseglob
+ break
+ ;;
+ esac
+ esac
+ done < <(bind -v)
+
keep=${BASHKEEP:-"$HOME"/.bashkeep.d}
declare -a keeps
keeps=("$keep"/"${COMP_WORDS[COMP_CWORD]}"*.bash)
diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash
index 658b5eb7..8e96abf7 100644
--- a/bash/bash_completion.d/man.bash
+++ b/bash/bash_completion.d/man.bash
@@ -35,6 +35,20 @@ _man() {
shopt -u dotglob
shopt -s extglob nullglob
+ # Make globbing case-insensitive if appropriate; is there a cleaner way
+ # to find this value?
+ while read -r _ option value ; do
+ case $option in
+ completion-ignore-case)
+ case $value in
+ on)
+ shopt -s nocaseglob
+ break
+ ;;
+ esac
+ esac
+ done < <(bind -v)
+
# Break manpath(1) output into an array of paths
declare -a manpaths
IFS=: read -a manpaths -r < <(manpath 2>/dev/null)
diff --git a/bash/bash_completion.d/mysql.bash b/bash/bash_completion.d/mysql.bash
index 2886f62e..d3cc1e7b 100644
--- a/bash/bash_completion.d/mysql.bash
+++ b/bash/bash_completion.d/mysql.bash
@@ -19,6 +19,20 @@ _mysql() {
# Set options so that globs expand correctly
shopt -s dotglob nullglob
+ # Make globbing case-insensitive if appropriate; is there a cleaner way
+ # to find this value?
+ while read -r _ option value ; do
+ case $option in
+ completion-ignore-case)
+ case $value in
+ on)
+ shopt -s nocaseglob
+ break
+ ;;
+ esac
+ esac
+ done < <(bind -v)
+
# Collect all the config file names, strip off leading path and .cnf
local -a cnfs
cnfs=("$dirname"/"${COMP_WORDS[COMP_CWORD]}"*.cnf)
diff --git a/bash/bash_completion.d/pass.bash b/bash/bash_completion.d/pass.bash
index feff78ae..e697f5d1 100644
--- a/bash/bash_completion.d/pass.bash
+++ b/bash/bash_completion.d/pass.bash
@@ -23,6 +23,20 @@ _pass()
shopt -u dotglob
shopt -s globstar nullglob
+ # Make globbing case-insensitive if appropriate; is there a cleaner way
+ # to find this value?
+ while read -r _ option value ; do
+ case $option in
+ completion-ignore-case)
+ case $value in
+ on)
+ shopt -s nocaseglob
+ break
+ ;;
+ esac
+ esac
+ done < <(bind -v)
+
# Gather the entries and remove their .gpg suffix
declare -a entries
entries=("$passdir"/"${COMP_WORDS[COMP_CWORD]}"*/**/*.gpg \
diff --git a/bash/bash_completion.d/path.bash b/bash/bash_completion.d/path.bash
index ba2dcb79..21180b1a 100644
--- a/bash/bash_completion.d/path.bash
+++ b/bash/bash_completion.d/path.bash
@@ -26,6 +26,20 @@ _path() {
# Set options to glob correctly
shopt -s dotglob nullglob
+ # Make globbing case-insensitive if appropriate; is there a cleaner way
+ # to find this value?
+ while read -r _ option value ; do
+ case $option in
+ completion-ignore-case)
+ case $value in
+ on)
+ shopt -s nocaseglob
+ break
+ ;;
+ esac
+ esac
+ done < <(bind -v)
+
# Collect directory names, strip trailing slash
local -a dirnames
dirnames=("${COMP_WORDS[COMP_CWORD]}"*/)
diff --git a/bash/bash_completion.d/sd.bash b/bash/bash_completion.d/sd.bash
index aeb76fa0..c3690172 100644
--- a/bash/bash_completion.d/sd.bash
+++ b/bash/bash_completion.d/sd.bash
@@ -17,6 +17,20 @@ _sd() {
# Set options to glob correctly
shopt -s dotglob nullglob
+ # Make globbing case-insensitive if appropriate; is there a cleaner way
+ # to find this value?
+ while read -r _ option value ; do
+ case $option in
+ completion-ignore-case)
+ case $value in
+ on)
+ shopt -s nocaseglob
+ break
+ ;;
+ esac
+ esac
+ done < <(bind -v)
+
# Collect directory names, strip leading ../ and trailing /
local -a dirnames
dirnames=(../"${COMP_WORDS[COMP_CWORD]}"*/)
diff --git a/bash/bash_completion.d/td.bash b/bash/bash_completion.d/td.bash
index db232dd6..f04a7984 100644
--- a/bash/bash_completion.d/td.bash
+++ b/bash/bash_completion.d/td.bash
@@ -9,6 +9,21 @@ _td() {
done < <(
shopt -s extglob nullglob
shopt -u dotglob
+
+ # Make globbing case-insensitive if appropriate; is there a cleaner way
+ # to find this value?
+ while read -r _ option value ; do
+ case $option in
+ completion-ignore-case)
+ case $value in
+ on)
+ shopt -s nocaseglob
+ break
+ ;;
+ esac
+ esac
+ done < <(bind -v)
+
declare -a fns
fns=("$dir"/"${COMP_WORDS[COMP_CWORD]}"*)
fns=("${fns[@]#"$dir"/}")
diff --git a/bash/bash_completion.d/ud.bash b/bash/bash_completion.d/ud.bash
index 47171b78..eb038e12 100644
--- a/bash/bash_completion.d/ud.bash
+++ b/bash/bash_completion.d/ud.bash
@@ -13,6 +13,20 @@ _ud() {
# Set options to glob correctly
shopt -s dotglob nullglob
+ # Make globbing case-insensitive if appropriate; is there a cleaner way
+ # to find this value?
+ while read -r _ option value ; do
+ case $option in
+ completion-ignore-case)
+ case $value in
+ on)
+ shopt -s nocaseglob
+ break
+ ;;
+ esac
+ esac
+ done < <(bind -v)
+
# Collect directory names, strip trailing slashes
local -a dirnames
dirnames=("${COMP_WORDS[COMP_CWORD]}"*/)