Bash tab completion script

This commit is contained in:
Rob Crittenden 2009-11-23 16:19:14 -05:00 committed by Jason Gerard DeRose
parent a094dfa91c
commit 8a7c22939d
2 changed files with 43 additions and 0 deletions

View File

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

View File

@ -245,6 +245,7 @@ rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
cd selinux
make install DESTDIR=%{buildroot}
cd ..
%else
make client-install DESTDIR=%{buildroot}
%endif
@ -275,6 +276,11 @@ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/
%endif
mkdir -p %{buildroot}/%{_localstatedir}/lib/ipa-client/sysrestore
%if ! %{ONLY_CLIENT}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
install -pm 644 contrib/completion/ipa.bash_completion $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/ipa
%endif
%clean
rm -rf %{buildroot}
@ -440,6 +446,7 @@ fi
%{_sbindir}/ipa-ldap-updater
%{_sbindir}/ipa-compat-manage
%{_sbindir}/ipa-nis-manage
%{_sysconfdir}/bash_completion.d
%endif
%files python
@ -474,6 +481,10 @@ fi
%endif
%changelog
* Fri Nov 13 2009 Rob Crittenden <rcritten@redhat.com> - 1.99-10
- Add bash completion script and own /etc/bash_completion.d in case it
doesn't already exist
* Tue Nov 3 2009 Rob Crittenden <rcritten@redhat.com> - 1.99-9
- Remove ipa_webgui, its functions rolled into ipa_httpd