1

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?

2 Answers 2

3

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).

1
  • 1
    In bash it functions. In csh and tcsh it seems not.
    – Hastur
    Jul 9, 2014 at 14:58
0

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).

3
  • 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, 2014 at 17:49
  • 1
    @Martin maybe Ctrl-n? It's equivalent to down key in many shells.
    – xuhdev
    Jul 8, 2014 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, 2014 at 19:18

You must log in to answer this question.

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