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.

2 Answers2

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

For bash: in your ~/.inputrc put:

set show-all-if-unmodified  on
Wes Hardaker
  • 2,716