Add new file that provides bash completion routine

This commit is contained in:
Karthik K 2015-04-13 17:24:15 +05:30
parent 27c39948ca
commit 9c24f50dee
2 changed files with 32 additions and 0 deletions

View File

@ -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
View 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: