diff options
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 |