« Gentoo ELOG ViewerVentrilo version 3(.03) on Gentoo (2009 temporary) »

Gentoo and Bash Completion


  08:16:39 pm, by   , 907 words  
Categories: Co-Lo Server

Gentoo and Bash Completion

Having the shell complete certain commands is handy, but I didn't realize I needed to explicitely enable it with Gentoo.

My latest installation had this at the end:

* Versions of bash-completion prior to 20060301-r1 required each user to
* explicitly source /etc/profile.d/bash-completion in ~/.bashrc. This
* was inconsistent with the completion modules which are
* enabled with eselect bashcomp. Now any user can enable the base
* completions without editing their .bashrc by running
* eselect bashcomp enable base
* The system administrator can also be enable this globally with
* eselect bashcomp enable --global base
* Additional completion functions can also be enabled or
* disabled using eselect's bashcomp module.
* If you use non-login shells you still need to source
* /etc/profile.d/bash-completion.sh in your ~/.bashrc.
* Note this is bash-completion.sh, not bash-completion. Lots of people
* overlook this

Following the suggestion to enable 'base' for all users:

# eselect bashcomp enable --global base

Then, following the other instruction, I looked at the .bashrc :

# cat ~/.bashrc
[[ -f /etc/profile.d/bash-completion ]] && source /etc/profile.d/bash-completion

# Midnight Commander chdir enhancement
if [ -f /usr/share/mc/mc.gentoo ]; then
. /usr/share/mc/mc.gentoo

Huh - just like the instructions said, there is no '/etc/profile.d/bash-completion' file, but their is a '/etc/profile.d/bash-completion.sh' file, so I need to modify that now :

# nano ~/.bashrc

- added in the '.sh' - as occasionally I do use non-login shells.

Then looking at what options are available and selected for bashcompletion

# eselect bashcomp list
Available completions:
[1] _subversion
[2] apache2ctl
[3] base
[4] bitkeeper
[5] bittorrent
[6] cksfv
[7] clisp
[8] cowsay *
[9] django
[10] dsniff
[11] eselect
[12] freeciv
[13] gcl
[14] gentoo
[15] git
[16] gkrellm
[17] gnatmake
[18] gpg2
[19] harbour
[20] isql
[21] larch
[22] lilypond
[23] lisp
[24] mailman
[25] mcrypt
[26] modules
[27] monodevelop
[28] mtx
[29] p4
[30] povray
[31] qdbus
[32] ri
[33] rkhunter *
[34] sbcl
[35] sitecopy
[36] snownews
[37] ssh
[38] subversion
[39] tree *
[40] unace
[41] unrar
[42] vim *
[43] xxd

Looking at these, I'd definately want 'base', 'gentoo' and 'eselect' going, and whatever else looks interesting - subversion, ssh, eix, genlop,.

Looking at another server, I saw this:

# eselect bashcomp list
Available completions:
[1] cowsay *
[2] eselect *
[3] genlop *
[4] git
[5] subversion

Hmm a very short list - I didn't have 'bash-completion' installed, although the USE flag had been set - better install it now:

# emerge -pv app-shells/gentoo-bashcomp

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild N ] app-shells/bash-completion-20081219-r1 90 kB
[ebuild N ] app-shells/gentoo-bashcomp-20050516 20 kB

Total: 2 packages (2 new), Size of downloads: 109 kB

# emerge -av app-shells/gentoo-bashcomp

Now my 'eselect bashcomp list' command results look better.

To immediately get the bash-completion going, simply run it:

# /etc/profile.d/bash-completion.sh

(This worked in one session, but not the other - you may have to start a new terminal session to get this going properly.)

Now I get great autocompletion for 'emerge' and many other commands:

# emerge [hit 'TAB' key after typing in a space after 'emerge']
Display all 162 possibilities? (y or n) y
app-accessibility/ app-xemacs/ dev-tinyos/ gpe-base/ net-im/ sci-electronics/ world
app-admin/ clean dev-util/ inject net-irc/ sci-geosciences/ www-apache/
app-antivirus/ depclean games-action/ java-virtuals/ net-libs/ sci-libs/ www-apps/
app-arch/ dev-ada/ games-arcade/ kde-base/ net-mail/ sci-mathematics/ www-client/
app-backup/ dev-cpp/ games-board/ kde-misc/ net-misc/ sci-misc/ www-misc/
app-benchmarks/ dev-db/ games-emulation/ lxde-base/ net-nds/ sci-physics/ www-servers/
app-cdr/ dev-dotnet/ games-engines/ mail-client/ net-news/ sci-visualization/ x11-apps/
app-crypt/ dev-embedded/ games-fps/ mail-filter/ net-nntp/ search x11-base/
app-dicts/ dev-games/ games-kids/ mail-mta/ net-p2p/ sec-policy/ x11-drivers/
app-doc/ dev-haskell/ games-misc/ media-fonts/ net-print/ sync x11-libs/
app-editors/ dev-java/ games-mud/ media-gfx/ net-proxy/ sys-apps/ x11-misc/
app-emacs/ dev-lang/ games-puzzle/ media-libs/ net-voip/ sys-auth/ x11-plugins/
app-emulation/ dev-libs/ games-roguelike/ media-plugins/ net-wireless/ sys-block/ x11-proto/
app-forensics/ dev-lisp/ games-rpg/ media-radio/ net-www/ sys-boot/ x11-terms/
app-i18n/ dev-ml/ games-server/ media-sound/ net-zope/ sys-cluster/ x11-themes/
app-laptop/ dev-perl/ games-simulation/ media-tv/ perl-core/ sys-devel/ x11-wm/
app-misc/ dev-php/ games-sports/ media-video/ prune sys-freebsd/ xfce-base/
app-mobilephone/ dev-php5/ games-strategy/ metadata regen sys-fs/ xfce-extra/
app-office/ dev-python/ games-util/ net-analyzer/ rox-base/ sys-kernel/
app-pda/ dev-ruby/ gnome-base/ net-dialup/ rox-extra/ sys-libs/
app-portage/ dev-scheme/ gnome-extra/ net-dns/ sci-astronomy/ sys-power/
app-shells/ dev-tcltk/ gnustep-apps/ net-firewall/ sci-biology/ sys-process/
app-text/ dev-tex/ gnustep-base/ net-fs/ sci-calculators/ system
app-vim/ dev-texlive/ gnustep-libs/ net-ftp/ sci-chemistry/ unmerge

# emerge -av web [hit 'TAB' key after typing in 'web']
webalizer webcomics-collector webgen webkit-sharp webob webtest
webapp-config webcpp webgraph weblint webpy webut
webby-fonts webfs webhelpers webmin webscarab
webcdwriter webfuzzer webkit-gtk webmo websvn

# emerge -av www-apache/ [hit 'TAB' key after typing in 'www-apache/']
anyterm mod_auth_pgsql mod_diagnostics mod_layout mod_perl mod_tidy
libapreq2 mod_auth_tkt mod_dnsbl_lookup mod_ldap_userdir mod_proxy_html mod_transform
mod_access_dnsbl mod_authn_pam mod_dnssd mod_limitipconn mod_python mod_umask
mod_ap2_snmp mod_authnz_external mod_evasive mod_lisp2 mod_roaming mod_vdbh
mod_auth_cookie_mysql2 mod_backtrace mod_extract_forwarded mod_loadavg mod_rpaf mod_vhost_ldap
mod_auth_imap2 mod_bw mod_fastcgi mod_log_rotate mod_ruby mod_vhs
mod_auth_kerb mod_caucho mod_fcgid mod_log_sql mod_scgi mod_watch
mod_auth_mysql mod_cband mod_flvx mod_loopback mod_security mod_whatkilledus
mod_auth_nufw mod_chroot mod_ftpd mod_macro mod_spin mod_wsgi
mod_auth_openid mod_cplusplus mod_gnutls mod_mono mod_suphp passenger
mod_auth_pam mod_depends mod_jk mod_pcgi2 mod_tcl pwauth

Woohoo - looks good and will be very handy in the long run.

Some handy sites I found along the way:


which were all blogs - looks like blogs are becoming the best places to go for small howto's and general answers - good work everyone ;D

1 comment

Comment from: Willie Matthews [Visitor]
Willie Matthews

Thanks for the tip on this. I have been trying to figure out how to get bash completion to work for awhile now.

2011/11/19 @ 22:06

This post has 82 feedbacks awaiting moderation...

Form is loading...

March 2021
Mon Tue Wed Thu Fri Sat Sun
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
 << <   > >>
Entries concerning computer ...


  XML Feeds

powered by b2evolution free blog software