blob: 1cb4bd072af4b72ca85132c218071e7388518f3d (
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
24
25
26
27
28
29
30
31
32
|
# Some simple completion for openssl(1ssl)
_openssl() {
# Needs openssl(1ssl)
hash openssl 2>/dev/null || return
# Only complete the first word: OpenSSL subcommands
((COMP_CWORD == 1)) || return
# Iterate through completions produced by subshell
local ci comp
while read -r comp ; do
COMPREPLY[ci++]=$comp
done < <(
# Run each of the command-listing commands; read each line into an
# array of subcommands (they are printed as a table)
for list in commands digest-commands cipher-commands ; do
openssl list -"$list"
done | {
declare -a subcmds
while read -a subcmds -r ; do
for subcmd in "${subcmds[@]}" ; do
case $subcmd in
("$2"*) printf '%s\n' "$subcmd" ;;
esac
done
done
}
)
}
complete -F _openssl -o bashdefault -o default openssl
|