From 476a90de537766cfbe935e409e3e39f3dcdd037d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 30 Jul 2016 01:18:36 +1200 Subject: Rename vis completion to eds --- bash/bash_completion.d/eds.bash | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bash/bash_completion.d/eds.bash (limited to 'bash/bash_completion.d/eds.bash') 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 -- cgit v1.2.3