Auto-complete command line arguments

Viewed 39164

In bash, executables such as mplayer and imagemagick's "convert" have a cool auto-complete functionality on their command line arguments. For instance, if I type

mplayer <tab><tab>

in one of my video folders, then mplayer will list all media files located in that folder, and only the media files.

Similarly, if I type

convert -<tab><tab>

then I will see all the possible options of the convert script, which is great.

My question is how to achieve a similar functionality, using bash, ruby or python scripts?

4 Answers

How do I enable bash completion on Ubuntu?

sudo apt-get install bash-completion

source /etc/profile.d/bash_completion.sh

sudo apt i[TAB]
Related