summaryrefslogtreecommitdiffstats
path: root/contrib/completion/ipa
diff options
context:
space:
mode:
authorPetr Spacek <pspacek@redhat.com>2016-11-03 10:34:53 +0100
committerMartin Babinsky <mbabinsk@redhat.com>2016-11-09 13:08:32 +0100
commitd3cab75d7e79fbc89ef08df3e6d2b1e28b4ef163 (patch)
tree5d053aeb4a43c95a1e4a42e72cda91324fafe00c /contrib/completion/ipa
parent8ffd3bdf142f0f852918186ce0a338a7818bbe8e (diff)
Build: integrate contrib directory into build system
BASH completion is now installed by make install. https://fedorahosted.org/freeipa/ticket/6418 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Christian Heimes <cheimes@redhat.com>
Diffstat (limited to 'contrib/completion/ipa')
-rw-r--r--contrib/completion/ipa32
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/completion/ipa b/contrib/completion/ipa
new file mode 100644
index 000000000..33ad1709b
--- /dev/null
+++ b/contrib/completion/ipa
@@ -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 2>/dev/null | 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