How can I make bash tab completion behave like vim tab completion and cycle through matching matches?
For bash >= 4 you might like these settings. You can try them directly on the command-line, and put them in your .bashrc
if you like them.
# If there are multiple matches for completion, Tab should cycle through thembind 'TAB':menu-complete# Display a list of the matching filesbind "set show-all-if-ambiguous on"# Perform partial completion on the first Tab press,# only start cycling full results on the second Tab pressbind "set menu-complete-display-prefix on"
This setup is similar to Vim's set wildmode=longest:full:list,full
I pulled these settings from this question on the Unix & Linux site.
By the way, since you are here, here is another nice pair of bindings:
# Cycle through history based on characters already typed on the linebind '"\e[A":history-search-backward'bind '"\e[B":history-search-forward'
This means if you type ssh<Up>
it will cycle through previous lines where you ran ssh
If you don't like what you got, you can clear the line with Ctrl-K Ctrl-U
I pulled these settings from this question on AskUbuntu.
On top of
# cycle forwardControl-k: menu-complete# cycle backwardControl-j: menu-complete-backward
you may also consider adding
# display one column with matchesset completion-display-width 1
This way you would preserve the current Tab functionality and make bash display the possibilities in one column. So instead of
file_12340983421 file_12390983421 file_12390986421 file_12391983421
you would get
file_12340983421file_12390983421file_12390986421file_12391983421
P.S. You can get up to date readline
library from this The GNU Readline Library website.