Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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.

share|improve this answer
    
No, that's something different. –  Ian Thompson Aug 24 '11 at 9:31
add comment
up vote 1 down vote accepted

Add

set autoexpand

to .tcshrc to activate this feature.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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