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.

I'm sure I read it somewhere, but I cannot find the site any more.

Basically I want to search the history "^r" and then execute a command and leave me at the next/previous position in the history. since generally there are commands that I run together it makes sense to be able to easily execute those commands again in sequence.

For example lets say I have 3 commands in the history and I execute the oldest command (3) I would then want to see command 2 in on my command line and if I press up I would see command 3 and down would give me command 1. So in this case after executing command 3 I would be in the same state as if I had pressed up twice from a blank prompt.

Thanks All

Piers

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Press Ctrl-o (letter Oh) to execute the command you retrieved and the next command in history will appear at the prompt ready for you to press Ctrl-o or Enter, etc.

Edit:

This command binds Ctrl-Alt-o to a keyboard macro that performs the selected command and moves to the previous one:

bind '"\e\C-o": "\C-o\C-p\C-p"'

You can save this so it's persistent in future sessions by adding the following to your ~/.inputrc:

"\e\C-o": "\C-o\C-p\C-p"
share|improve this answer
    
Wow, thank you so much! I found it in the manual now "operate-and-get-next (C-o) Accept the current line for execution and fetch the next line relative to the current line from the history for editing. Any argument is ignored. " –  PiersyP Feb 11 '11 at 10:32
    
It should really be in the history section but instead it comes under miscellaneous commands. Pity to see that there is no operate and get previous :( –  PiersyP Feb 11 '11 at 10:33
    
@PiersyP: See my edited answer. –  Dennis Williamson Feb 11 '11 at 10:40

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.