author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Wed, 29 Mar 2023 23:42:06 +0300 | |
changeset 1018 | 831e2c1bf980 |
parent 825 | b1536ac2ff88 |
permissions | -rw-r--r-- |
825
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
# -*- mode: sh; sh-shell-file: bash -*- |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
|
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
_figlet() { |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
local cur=${COMP_WORDS[COMP_CWORD]} |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
case "$cur" in |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
-*) |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
COMPREPLY=( $(compgen -W '-f -d -c -l -r -x -t -w -p -n -D -E -C -N -s -S -k -W -o -m -v -I -L -R -X' -- "$cur") ) |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
return 0 |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
;; |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
esac |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
11 |
if [[ $COMP_CWORD -le 1 ]]; then |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
return 0 |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
fi |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
14 |
local prev=${COMP_WORDS[COMP_CWORD-1]} |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
case "$prev" in |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
16 |
-f) |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
17 |
local fonts=( $(cd /usr/share/figlet/; echo *.flf) ) |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
18 |
fonts=( ${fonts[@]%.flf} ) |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
COMPREPLY=( $(compgen -W '${fonts[@]}' -- "$cur") ) |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
20 |
return 0 ;; |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
21 |
-d) |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
22 |
COMPREPLY=( $(compgen -d -- "$cur") ) |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
23 |
return 0 ;; |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
24 |
esac |
b1536ac2ff88
Add completion for figlet.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
25 |
} && complete -F _figlet figlet |