5

I’m a long time tcsh user, but all the cool kids seem to be using either bash or zsh nowadays (that is, completion patterns for git or stuff are available for bash and zsh, rarely for tcsh).

My problem is that both shells have behaviours regarding tab-completion of paths that drive me crazy, and I’m having much trouble finding how to change them to my liking.

Here’s a couple of examples of what I’m used to doing in tcsh that the others do differently:

  • /u<TAB> completes to /usr/
  • Then tab lists the contents of /usr/
  • /usr/li<TAB> completes to /usr/lib and lists lib/ and libexec/
  • Pressing tab a second time completes to /usr/lib/
  • Pressing tab a third time lists the contents of /usr/lib/

In bash, no matter how many times I hit tab, it will never go past /usr/lib, requiring me to type the slash, which I don’t want to do.

In zsh, /usr/li<TAB> first completes to /usr/lib, then another tab lists lib/ and libexec/, a third time tab completes to /usr/lib/, and all subsequent tabs cycle between /usr/lib/ and /usr/libexec/. I have no idea how to get past this point. I just want to go from /usr/li to /usr/lib, then /usr/lib/, then list its contents.

Same goes for python. In tcsh, I type pyt<TAB>, it completes to python and lists python, python2.5, python2.6, etc, then a second tab settles for python and add the space. In bash it requires me to type the space and in zsh it cycles endlessly like in the first example.

Any help in taming these shells would be greatly appreciated. I don’t really want to spend time tweaking the other aspects of these shells until I solve the problem above.

4
  • Part of learning a new environment is getting used to how it works. man bash /completion May 5, 2011 at 13:38
  • I can’t help but think that this comment is both condescending and suggesting that I adapt to how bash works. Please correct me if I’m wrong, I’d love to. May 7, 2011 at 23:41
  • It's not meant to be condescending, but it is an inevitable fact that different software likely has slightly different features. May 7, 2011 at 23:44
  • Hence my asking, because me not finding a way to do something does not necessarily mean that it cannot be done. :) Like the rec_exact option suggested below for zsh: it does exactly what I want, but I don't remember it popping up in my searches, and even if it did, I'm not sure I'd have understood that it was what I was looking for. May 9, 2011 at 8:34

2 Answers 2

2

Well done on describing your requirements precisely, but I'm not sure I actually understand what you want to do if there's an ambiguity, e.g. after /usr/lib, what you expect the Tab key to do.

If I try tcsh, after /usr/lib, the Tab key only lists lib and libexec. You can reproduce this effect in zsh with setopt no_auto_menu, but this may change the behavior in ways you don't like in other cases. If you also do setopt rec_exact, the behavior looks like what you describe: after /usr/li, Tab inserts b, then another Tab inserts /, and a third lists completions in /usr/lib/.

The zsh completion options are documented under “Completion” in man zshoptions.

1
  • It's exactly that, thanks a lot. In the meantime I also found out about oh-my-zsh, started tweaking my prompt and looking for an alternative to Apple's Terminal that supports customisation of the colours. It's gonna be fun! :) May 9, 2011 at 8:36
1

For bash: in your ~/.inputrc put:

set show-all-if-unmodified  on

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .