aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/eds.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-02 18:03:15 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-02 18:03:15 +1300
commit693fc13bb98b17938f2208fbadaec1996822fc5e (patch)
tree4a9cc6179f521528c663c8ab5f3bbc59dc57eaa0 /bash/bash_completion.d/eds.bash
parentMerge branch 'release/v2.6.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-693fc13bb98b17938f2208fbadaec1996822fc5e.tar.gz
dotfiles-693fc13bb98b17938f2208fbadaec1996822fc5e.zip
Merge branch 'release/v2.7.0'v2.7.0
* release/v2.7.0: (22 commits) Bump VERSION Make separate install-bash-completion target Overhaul Bash completion scripts Reduce ud() completion to just dirnames Upgrade uncap_ex.vim plugin to v0.3.0 Apply syntax fixes to last _text_filenames specs Rearrange _text_filenames completion a little Remove prompt() completion Throw away chgrp completion Throw away Git Bash completion Remove mysql(1) completion Use consistent temp names for shell subfile vars Overhaul pass(1) completion Adjust syntax of two more completion loads Remove ftp(1) completion Remove `kill` completion Use the positional parameter aliases for words Overhaul bd() completion again Remove unneeded -q option to shopt -s commands Don't include dotfiles in keep() names ...
Diffstat (limited to 'bash/bash_completion.d/eds.bash')
-rw-r--r--bash/bash_completion.d/eds.bash52
1 files changed, 24 insertions, 28 deletions
diff --git a/bash/bash_completion.d/eds.bash b/bash/bash_completion.d/eds.bash
index 1c5b2aa2..371962ca 100644
--- a/bash/bash_completion.d/eds.bash
+++ b/bash/bash_completion.d/eds.bash
@@ -1,38 +1,34 @@
-# Complete args to eds(1df) with existing executables in $EDSPATH, defaulting
-# to ~/.local/bin
+# 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
+
+# Complete args to eds(1df)
_eds() {
- local edspath
- edspath=${EDSPATH:-"$HOME"/.local/bin}
- [[ -d $edspath ]] || return
- local executable
- while IFS= read -rd '' executable ; do
- [[ -n $executable ]] || continue
- COMPREPLY[${#COMPREPLY[@]}]=$executable
+
+ # Iterate through completions produced by subshell
+ local ci comp
+ while IFS= read -d / -r comp ; do
+ COMPREPLY[ci++]=$comp
done < <(
- shopt -s dotglob 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)
+ # Make globs expand appropriately
+ shopt -u dotglob
+ shopt -s nullglob
+ if _completion_ignore_case ; then
+ shopt -s nocaseglob
+ fi
- declare -a files
- files=("${EDSPATH:-"$HOME"/.local/bin}"/"${COMP_WORDS[COMP_CWORD]}"*)
- declare -a executables
- for file in "${files[@]}" ; do
+ # Iterate through files in local binaries directory
+ edspath=${EDSPATH:-"$HOME"/.local/bin}
+ for file in "$edspath"/"$2"* ; do
+ # Skip directories
! [[ -d $file ]] || continue
- [[ -e $file ]] || continue
+ # Skip non-executable files
[[ -x $file ]] || continue
- executables[${#executables[@]}]=${file##*/}
+ # Print entry, null-terminated
+ printf '%q\0' "${file##*/}"
done
-
- # Print quoted entries, null-delimited
- printf '%q\0' "${executables[@]}"
)
}
complete -F _eds eds