4

I use tcsh, and I'd like to set up the following behaviour, which I've seen on some systems in the past. If I type

!string TAB

then:

  • If the history contains a unique entry beginning with string, autocompletion should take place, and I can edit the resulting command, or just press return to execute it.

  • If the history contains multiple entries beginning with string, a list of possible completions is displayed, the command is partially completed as far as possible (without eliminating any possibilities from the list), and on the command line I should have an exclamation mark followed by the partially completed command, so that I can type more characters and press TAB again.

How do I achieve this?

2

Add

set autoexpand

to .tcshrc to activate this feature.

1

Probably, you are searching for history-search-backward and history-search-forward editor commands.

As default, these commands are binded to M-p (usually alt+p on pc keyboards) and M-n (alt+n).

You can re-bind them to any other key sequence using bindkey command. E.g.:

 bindkey '\t' history-search-backward

Note that you do not need to place a ! at line beginning to use these commands.

  • No, that's something different. – Ian Thompson Aug 24 '11 at 9:31
  • @infoclogged thank you, I fixed the typo in the example – andcoz Jun 24 '15 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.