summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2009-11-23 16:19:14 -0500
committerJason Gerard DeRose <jderose@redhat.com>2009-11-25 08:48:38 -0700
commit8a7c22939df36e40f32fa96c535e609791482b11 (patch)
tree1cb402365e6ee61e748ac1f3c4dcdea6c8ac993a /contrib
parenta094dfa91c88c1bd594b9fc29c8ba3639d3b3e90 (diff)
downloadfreeipa-8a7c22939df36e40f32fa96c535e609791482b11.zip
freeipa-8a7c22939df36e40f32fa96c535e609791482b11.tar.gz
freeipa-8a7c22939df36e40f32fa96c535e609791482b11.tar.xz
Bash tab completion script
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/ipa.bash_completion32
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/completion/ipa.bash_completion b/contrib/completion/ipa.bash_completion
new file mode 100644
index 0000000..36b82bd
--- /dev/null
+++ b/contrib/completion/ipa.bash_completion
@@ -0,0 +1,32 @@
+# -*- shell-script -*-
+# Programmable completion for the IPA ipa command under bash. Source
+# this file (or on some systems add it to ~/.bash_completion and start a new
+# shell) and bash's completion mechanism will know all about ipa's options!
+
+# Known to work with bash 2.05a with programmable completion and extended
+# pattern matching enabled (use 'shopt -s extglob progcomp' to enable
+# these if they are not already enabled).
+
+# based on the bzr bash completion script by Martin Pool
+
+_ipa_commands()
+{
+ ipa help commands | sed -r 's/^([-[:alnum:]]*).*/\1/' | grep '^[[:alnum:]]'
+}
+
+_ipa()
+{
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+ if [ $COMP_CWORD -eq 1 ]; then
+ COMPREPLY=( $( compgen -W "$(_ipa_commands)" $cur ) )
+ elif [ $COMP_CWORD -eq 2 ]; then
+ case "$prev" in
+ help)
+ COMPREPLY=( $( compgen -W "$(_ipa_commands) commands" $cur ) )
+ ;;
+ esac
+ fi
+}
+
+complete -F _ipa -o default ipa