RedHat – yum install completion

redhat

I had been using Ubuntu and recently migrated to RedHat.
The apt-get install auto completion is very handy, so I supposed yum install should have this function as well, but seemed it doesn't.
Is there package name tab completion of yum install ?

Best Answer

first check that you have the bash_completion package installed;

$ rpm -qa | grep compl
bash-completion-2.1-2.fc18.noarch

If you are on rhel/centos, check that it being sourced in your .bashrc file, like so;

$ cat ~/.bashrc | grep -A3 '\[ -f /etc/bash_completion \]'
if [ -f /etc/bash_completion ]; then
   . /etc/bash_completion
fi

otherwise bash_completions are loaded from /etc/profile.d on fedora;

$ ls -1 /etc/profile.d/ | grep compl
bash_completion.sh
udisks-bash-completion.sh

to test it, you can manually source the file, and see if it working as you want; (centos/rhel)

$ source /etc/bash_completion

if you are using fedora, you will need this instead;

$ source /etc/profile.d/bash_completion.sh

note:

whether this is the best way to search for installable packages is debatable, but I actually didn't realise you could do this until I just tried....

$ yum install 
Display all 40991 possibilities? (y or n)

0ad-data.noarch
0ad-debuginfo.x86_64
0xFFFF-debuginfo.x86_64
0xFFFF.x86_64
389-admin-console-doc.noarch
389-admin-console.noarch
389-admin-debuginfo.x86_64
389-admin.i686
389-adminutil-debuginfo.x86_64
389-adminutil-devel.i686
389-adminutil-devel.x86_64
389-ds-base-libs.x86_64
389-ds-base.x86_64
389-ds-console-doc.noarch

... ...

etc etc