Bash completion has finally arrived on OpenSolaris - as of snv_126!
Unfortunately, for some reason it's not enabled by default - but it's not that difficult to enable it, the simple steps are:
- Create /etc/bash/bash_completion:
# cp /etc/bash/bash_completion.example /etc/bash/bash_completion
- Edit ${HOME}/.bashrc and add lines like:
if [ -f /etc/bash/bash_completion ]; then
. /etc/bash/bash_completion
fi
- ssh <TAB><TAB>
<list of known hosts> - su - <TAB><TAB>
<list of users in /etc/password> - evince <TAB><TAB>
<list of dirs, ps and pdf files in current directory>
Adding other completions
Of course these are only the default completions, it's possible to add many more! The simplest way to do this is to place a file in /etc/bash/bash_configuration.d and these files will be sourced automatically if you added the lines mentioned above to your .bashrc file.
A useful one for those of us using Mercurial is the version you get in /usr/demo/mercurial - this can be copied in and hey presto you have completion of the mercurial commands:
- # cp /usr/demo/mercurial/bash_completion /etc/bash/bash_completion.d/
- $ hg <TAB><TAB>
active bisect cddlchk copyright hdrchk init mv permchk reparent showconfig update
add blame checkout cp heads jstyle nits pull resolve st verify
...
It's possible to add more completion for various commands, for example you could create one for zfs, zpool, pkg, etc. - the possibilities are to numerous to mention, but here are a few I found:
- http://www.sun.com/bigadmin/scripts/sunScripts/zfs_completion.bash.txt
- Loads more (although Linux focused) at: http://bash-completion.alioth.debian.org/
Enjoy
