forked from pystardust/ani-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_ani-cli-bash
45 lines (38 loc) · 1.03 KB
/
_ani-cli-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
39
40
41
42
43
44
45
#!/bin/bash
_ani_cli_autocomplete() {
local cur prev opts
# Get the current and previous words in the command line
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Define the main options
opts="
-c --continue
-d --download
-D --delete
-s --syncplay
-S --select-nth
-q --quality
-v --vlc
-V --version
-h --help
-e --episode
--dub
--rofi
--skip
--no-detach
-N --nextep-countdown
-U --update
"
# Check for conditional options
if [[ "${COMP_WORDS[@]}" =~ "--no-detach" ]]; then
opts+=" --exit-after-play"
fi
if [[ "${COMP_WORDS[@]}" =~ "-e" || "${COMP_WORDS[@]}" =~ "--episode" ]]; then
opts+=" -r --range"
fi
# Use `compgen` to generate the options based on the current word
COMPREPLY=($(compgen -W "${opts}" -- "$cur"))
}
# Register the completion function for `ani-cli`
complete -F _ani_cli_autocomplete ani-cli