Pacman autocompletion: enable it on ArchLinux

As we all know the names of the packages in the repository are not always simple, and if the spelling is not correct maybe you can lost a lot of time thought the problem is other. To overpass this problem you can allow the pacman autocompletion (as indicate in a forum here).

Firstable you have to download and install the package bash-completion:

[email protected]~ pacman -S bash-completion

then you need to eneble it in ~/.bashrc just adding the following lines to the file (1):

if [ -f /etc/bash_completion ]; then
    /etc/bash_completion
fi

Now you can simple use the tab to autocomplete package’s names using pacman (or yaourt).
If you need autocomplete for a different shell you can search it on the ArchLinux wiki.

####################################################

(1) As adviced by Andrei is possible to write this script in a different way, to support others shells and extra operators, is the follow:

if [[ -f /etc/bash_completion ]]; then
    /etc/bash_completion
fi

About Daniele Dalla Torre

I’m a Civil Engineering student but I love to learn everything about technology, from the basics to the new frontiers!

Here my gpg public key!

2 Replies to “Pacman autocompletion: enable it on ArchLinux”

    • As you can find on Bash Reference Manual [[]] is a new version of [] that allow to use more constructors and is portable on others shell.

      The script of the article is written only for bash shell and with supported conditional constructor by [].

      Thanks for your comment, we will add your solution, because is a different way (better in general) to write it.

Leave a Reply

Your email address will not be published.

*