From 9c24f50dee909e3c2405401cec7707a08774fcd1 Mon Sep 17 00:00:00 2001 From: Karthik K Date: Mon, 13 Apr 2015 17:24:15 +0530 Subject: [PATCH] Add new file that provides bash completion routine --- Makefile | 1 + bash_completion | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 bash_completion diff --git a/Makefile b/Makefile index 992a16e..50e06a2 100644 --- a/Makefile +++ b/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 diff --git a/bash_completion b/bash_completion new file mode 100644 index 0000000..a7d1f79 --- /dev/null +++ b/bash_completion @@ -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: