Le Bagage, Gautier Pelloux-Prayer

You are here:   Home > Reminders > Bash > Autocomplete & menu selection

Autocomplete & menu selection

  • Issue: how can we do give zsh behaviour to bash meaning TAB smart key.  Just try it out, and you'll like it Clin d'œil.
  • Features:
$ ls
automate  bin  Desktop  public_html  sauvegarde  travail  zsh-4.3.6-70.23.i586.rpm
$ cd d[TAB] --> 
$ cd Desktop
$ gen[TAB]
gencat         genhomedircon  genhostid      genisoimage    
$ gencat[TAB]
$ genhomedircon
  • Solution:

If you got root privileges:

  1. Install bash-completion:
    $ aptitude install bash-completion
  2. Insert into ~/.bashrc:

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

  1. Finally in ~/.inputrc:

set completion-ignore-case on
set show-all-if-ambiguous on
set show-all-if-unmodified on
"\C-i": menu-complete

 

Otherwise you need to (adjust MPP to your own path):

  1. Manually install bash-completion (cf ce ticket)
  2. Edit these lines from bash_completion. Don't forget to replace MPP (absolute path):

MPP=/home/toto/bash-completion
[ -n "$BASH_COMPLETION" ] || BASH_COMPLETION=$MPP/etc/bash_completion
[ -n "$BASH_COMPLETION_DIR" ] || BASH_COMPLETION_DIR=$MPP/etc/bash_completion.d
[ -n "$BASH_COMPLETION_COMPAT_DIR" ] || BASH_COMPLETION_COMPAT_DIR=$MPP/etc/bash_completion.d

  1. Then in ~/.bashrc:

if [ -f /home/toto/bash-com​pletion/etc/bash_completion ]; then
   . /home/toto/bash-completion/etc/bash_completion
fi

  1. Finally, insert in ~/.inputrc:

set completion-ignore-case on
set show-all-if-ambiguous on
set show-all-if-unmodified on
"\C-i": menu-complete

 

That's all folks!
 

Last edited:: September 24, 2013, 18:37