Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Once, a colleague of mine shown me a very useful method (shortcut?) on a shell (bash? csh?) to, after executing a previous command, automatically show the command after in history.

For example, here's my history:

$ ...
$ cd /var
$ cd www
$ ...

Then I pressed the up key to show cd /var, executed it a certain way then the prompt automatically displayed cd www.

Sorry, I can't remember more details, but that's why i'm asking... any idea?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I think you are looking for Ctrl-o which does something like: execute the current item in the history list and advance to the next one. So you move to a history entry and press Ctrl-o instead of Enter. The command executes and the next command in history appears at the prompt.

EDIT: Oh, I forgot to mention that this is in bash(I don't know if it works in other shells).

share|improve this answer
1  
In bash it functions. In csh and tcsh it seems not. –  Hastur Jul 9 at 14:58

I don't believe there's a way to have it automatically show the next command. If there is, it's probably very specific to the command shell you are using - but you don't seem to be sure which one you saw it on was. :)

Having said that, here's a more generic, yet plausible answer to what you witnessed:

Like the up arrow changes to the previous command in the chain, push the "down arrow" to change to the next command in the chain (if there is one).

share|improve this answer
    
ahah, no, it wasn't the down key, but something like typing ctrl<key> instead of enter. Maybe it was csh. Thanks for the answer however. –  Martin Jul 8 at 17:49
1  
@Martin maybe Ctrl-n? It's equivalent to down key in many shells. –  xuhdev Jul 8 at 18:21
1  
@xuhdev Ctrl-n, or down, is "go to the next command". I'm searching for "execute the command n and go to the n+1 command" –  Martin Jul 8 at 19:18

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.