blob: 23c1199d2c84d0a07aad7a21b9abd911a2bf3259 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# Complete args to vis(1) with existing executables in $VISPATH, defaulting to
# ~/.local/bin
_vis() {
local vispath
vispath=${VISPATH:-$HOME/.local/bin}
[[ -d $vispath ]] || return
while IFS= read -d '' -r executable ; do
COMPREPLY=("${COMPREPLY[@]}" "$executable")
done < <(
shopt -s dotglob nullglob
declare -a files
files=("${VISPATH:-$HOME/.local/bin}"/"${COMP_WORDS[COMP_CWORD]}"*)
declare -a executables
for file in "${files[@]}" ; do
[[ -x $file ]] || continue
executables=("${executables[@]}" "${file##*/}")
done
((${#executables[@]})) || exit 1
printf '%q\0' "${executables[@]}"
)
}
complete -F _vis vis
|