Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Set Tab-key completion to cycle through possibilities UNIX
Some time ago there, was an excellent hint for setting Tab-key filename completion to cycle through possible endings rather than simply show a list of possibilities. Unfortunately, that hint only applied to tcsh and not bash. To achieve the some result in bash, add this line to your .bash_login file:
bind '"\t":menu-complete'
[robg adds: This works as described, and I find the revised behavior so much nicer (it was one of the few things I missed when switching from tcsh. In the standard mode, you see a huge list of commands when typing (for instance) a[Tab]. You then have to type another letter, hit Tab again to see a revised list, and repeat as necessary. In this mode, you just type a[Tab] and then keep hitting Tab to see the other possibilities cycle through the same command line.]
    •    
  • Currently 3.71 / 5
  You rated: 5 / 5 (7 votes cast)
 
[16,905 views]  

Set Tab-key completion to cycle through possibilities | 12 comments | Create New Account
Click here to return to the 'Set Tab-key completion to cycle through possibilities' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set Tab-key completion to cycle through possibilities
Authored by: thaddeus on Sep 08, '05 10:37:00AM
Another option is zsh. To the average user it looks just like bash. The feature described in this hint is built in and works like a merge of bash's functionality and tcsh's just by hitting tab multiple times (it cycles and shows the menu).

Some other great features of zsh:

  1. vi or emacs key-bindings. If you're a vi user, you can use Esc-0-c-w for instance to change the command on a long line with many options. Most basic vi movement and editing functionality works and I'm pretty sure that's true for emacs bindings as well.
  2. Right-side prompts. Great for displaying the current directory, host name, or anything else on the right side of the command-line. Just set RPS1 and go. Plus it disappears when a long command runs into it, staying out of the way.

If you're a bash user and also use vi or emacs heavily, zsh is definitely worth a look if only for the key-bindings. Also, it's a great replacement for ksh. If you're interested check out http://zsh.sunsite.dk/FAQ/. I'm pretty sure it's standard on OS X, but I've been using it so long I can't be sure.

Just my $0.02

[ Reply to This | # ]

Set Tab-key completion to cycle through possibilities
Authored by: feyd on Sep 08, '05 11:49:38AM

This is isn't a very productive comment but...I have been using zsh on Linux and Mac OS X for years....and well



What he said ^_^.

Zsh is amazing for all its helpful little additions.



[ Reply to This | # ]
Set Tab-key completion to cycle through possibilities
Authored by: gidds on Sep 08, '05 02:56:01PM
Thirded.

My own absolute must-have feature is the recursive globbing. Any shell will expand * to a list of files in the current folder; but zsh will expand **/* to a list of files in the current folder and every folder inside it, recursively.

It's far more powerful than that, though -- you can easily get it to include or exclude files based on their size, attributes, owner, etc., and you can sort the results. It basically does everything find does, only more neatly and concisely, and because it's right there in the shell you don't have to faff around with quoting or pipelines.

zsh has lots more features, too, but that's the one I can't do without. I don't understand why more people don't use it!

---
Andy/

[ Reply to This | # ]

Set Tab-key completion to cycle through possibilities
Authored by: adrianm on Sep 08, '05 05:11:18PM
Yea, zsh is the dog's b*****ks.

put


autoload -U compinit
compinit
in your .zshrc and things like man tab will expand to all possible man pages, and tar xf hello.tar tab will expand to all files inside the tar file.

Just about all normal commands are catered for and it's fairly easy to extend.

I just don't see why people get so excited about bash, and don't get me started on [t]csh users.

[ Reply to This | # ]

Set Tab-key completion to cycle through possibilities
Authored by: wnorris on Sep 09, '05 12:25:40AM
vi or emacs key-bindings. If you're a vi user, you can use Esc-0-c-w for instance to change the command on a long line with many options. Most basic vi movement and editing functionality works and I'm pretty sure that's true for emacs bindings as well.
for vi bindings in bash
set -o vi
for emacs bindings in bash
set -o emacs


[ Reply to This | # ]
thank you so much!
Authored by: nick on Sep 09, '05 06:32:52AM

.



[ Reply to This | # ]
Set Tab-key completion to cycle through possibilities
Authored by: rootpoot on Sep 09, '05 02:48:23PM

I really, really want to switch to zsh, but the damn [Process Completed] bug is keeping me on bash.



[ Reply to This | # ]
Set Tab-key completion to cycle through possibilities
Authored by: mricart on Sep 08, '05 10:38:45AM
For those interested, I did that another way:

create (if not already there) a ~/.inputrc file and put in it the following line:

TAB: menu-complete

Also, I have this line to ignore input case for completion:

set completion-ignore-case On

as mentionned in http://www.macosxhints.com/article.php?story=20040308230106279

[ Reply to This | # ]

Set Tab-key completion to cycle through possibilities
Authored by: Pedro Estarque on Sep 08, '05 12:19:29PM

GREAT, Finally!
thanks



[ Reply to This | # ]
How about show a list that updates in place?
Authored by: lullabud on Sep 08, '05 02:51:19PM

zsh has the ability to show the possibilities, then when you type some more it replaces the displayed completions, rather than concatenating them out. Anybody know how to do that with bash?



[ Reply to This | # ]
Set Tab-key completion to cycle through possibilities
Authored by: nick on Sep 09, '05 06:36:44AM
if you're interested in more bind-command:

general explanation

bindable readline-commands

n.

[ Reply to This | # ]