Add new file that provides bash completion routine
This commit is contained in:
parent
27c39948ca
commit
9c24f50dee
1
Makefile
1
Makefile
@ -4,3 +4,4 @@ all:
|
||||
install:
|
||||
cp create_ap /usr/bin/create_ap
|
||||
[ ! -d /lib/systemd/system ] || cp create_ap.service /lib/systemd/system
|
||||
[ ! -d /usr/share/bash-completion/completions ] || cp bash_completion /usr/share/bash-completion/completions/create_ap
|
||||
|
31
bash_completion
Normal file
31
bash_completion
Normal file
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Bash Completion routine for create_ap
|
||||
#
|
||||
|
||||
_create_ap() {
|
||||
awk_cmd='
|
||||
($1 ~ /^-/){
|
||||
for (i = 1; i <= NF; i++) {
|
||||
if ($i ~ /,$/) {
|
||||
print substr ($i, 0, length ($i)-1)
|
||||
}
|
||||
else {
|
||||
print $i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
'
|
||||
|
||||
local cur prev opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts=$("$1" --help | awk "$awk_cmd")
|
||||
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- $cur) )
|
||||
return 0
|
||||
}
|
||||
complete -F _create_ap create_ap
|
||||
|
||||
# vim: set ft=sh:
|
Loading…
Reference in New Issue
Block a user