diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-07-30 01:18:36 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-07-30 02:09:30 +1200 |
commit | 476a90de537766cfbe935e409e3e39f3dcdd037d (patch) | |
tree | 1c6a7bf29cd297d14fe08989f6a5bc31ac7a6906 /bash/bash_completion.d/eds.bash | |
parent | Move bash completion setup into separate dir (diff) | |
download | dotfiles-476a90de537766cfbe935e409e3e39f3dcdd037d.tar.gz dotfiles-476a90de537766cfbe935e409e3e39f3dcdd037d.zip |
Rename vis completion to eds
Diffstat (limited to 'bash/bash_completion.d/eds.bash')
-rw-r--r-- | bash/bash_completion.d/eds.bash | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bash/bash_completion.d/eds.bash b/bash/bash_completion.d/eds.bash new file mode 100644 index 00000000..8d0f6067 --- /dev/null +++ b/bash/bash_completion.d/eds.bash @@ -0,0 +1,22 @@ +# Complete args to eds(1) with existing executables in $EDSPATH, defaulting to +# ~/.local/bin +_eds() { + local edspath + edspath=${EDSPATH:-"$HOME"/.local/bin} + [[ -d $edspath ]] || return + while IFS= read -rd '' executable ; do + COMPREPLY[${#COMPREPLY[@]}]=$executable + done < <( + shopt -s dotglob nullglob + declare -a files + files=("${EDSPATH:-"$HOME"/.local/bin}"/"${COMP_WORDS[COMP_CWORD]}"*) + declare -a executables + for file in "${files[@]}" ; do + [[ -f $file && -x $file ]] || continue + executables[${#executables[@]}]=${file##*/} + done + ((${#executables[@]})) || exit 1 + printf '%q\0' "${executables[@]}" + ) +} +complete -F _eds eds |