-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathyt.bash-completion
56 lines (47 loc) · 1.43 KB
/
yt.bash-completion
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#bash completion for yt
_yt()
{
#When the function or command is invoked, the first argument is the name of
#the command whose arguments are being completed, the second argument is the
#word being completed, and the third argument is the word preceding the word
#being completed on the current command line.
#program_name=$1
#cur=$2
#prev=$3
#defining local vars
local cur prev opts
COMPREPLY=() #clean out last completions
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
OPTS="-h --help --player --novideo --bandwidth"
#=======================================================
# Nested options <1st layer>
#=======================================================
player_opts="mplayer omxplayer"
########################################################
# -W wordlist
# -A action (see bash 'complete' build-in command)
# -G globalpath
# -C command
# -F function
# -X filterpath
# -P preffix
# -S suffix
case "${prev}" in
##1st layer
--player)
COMPREPLY=( $( compgen -W "$player_opts" -- $cur ))
return 0
;;
esac
#general options
case "${cur}" in
-*)
COMPREPLY=( $( compgen -W "$OPTS" -- $cur ))
;;
*)
COMPREPLY=( $( compgen -W "$OPTS" -- $cur ))
;;
esac
}
complete -F _yt yt