-
Notifications
You must be signed in to change notification settings - Fork 0
/
gotoimp-completion.bash
38 lines (30 loc) · 1018 Bytes
/
gotoimp-completion.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
_GoToImpCompletions()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
case "$cur" in
[a-zA-Z]*)
words="$(goto -l | tail +3 | grep -E -v '^\s*$' | awk '{print $1}' | tr "\n" " ")"
# words=""
# for word in $(goto -l | tail +3 | grep -E -v '^\s*$' | awk '{print $1}' | tr -d "\n"); do
# for word in $(goto -l | tail +3 | grep -E -v '^\s*$' | awk '{print $1}' | tr "\n" " "); do
# words="$words $word"
# done
words="${words%%[[:space:]]}" # Remove trailing spaces
words="${words##[[:space:]]}" # Remove leading spaces
printf "\n\$words: ${words}\n"
COMPREPLY=( $(compgen -W "$words" -- $cur ) )
;;
*)
echo "Unknown option '$cur'" 1>&2
;;
esac
return 0
}
# complete -F _GoToImpCompletions -o filenames goto
words="$(goto -l | tail +3 | grep -E -v '^\s*$' | awk '{print $1}' | tr "\n" " ")"
words="${words%%[[:space:]]}" # Remove trailing spaces
words="${words##[[:space:]]}" # Remove leading spaces
# echo complete -W "$words" goto
complete -W "$words" goto