You can enable menu-complete
in Bash to step through the entries on the command line each time you press Tab. This is not really what you're looking for. If you want to try it, do this at the command prompt:
bind '"\C-i": menu-complete'
To make it persist, add this to your ~/.inputrc
file:
"\C-i": menu-complete
Zsh has a feature that allows you to use the arrow keys to select an entry. Add this (or another variation) to your ~/.zshrc
file:
zstyle ':completion:*' menu select=0
See man zshcompsys
and search for "select=" (it will be in the section for the menu
"Standard Style") for more information.
Otherwise, in Bash, you could write a function (or even create your own completion function) that would do something based on the select
command. This is extremely simplistic:
$ select a in x y z; do cd $a; done
1) x
2) y
3) z
#?
You'd have to flesh that out a lot to get it to do what you want.
I like your
select
solution. That's exactly what I wanted! I added abreak
aftercd $a
, and I'll alias this command. That's way better than tab completion. – dehmann – 2010-08-04T16:58:56.607@dehman: It's part of "flesh that out". You need a
– Paused until further notice. – 2010-08-04T17:00:15.710break
statement. Try:select a in x y z; do cd $a; break; done
. You can usefind
to build the list of directories to choose from rather than hardcoding them. Another thing you might want to look into is theCDPATH
variable (and here).