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.

Say I have a hundred commands in my shell's history, and now I'd like to repeat commands 74 through 78. In the emacs mode of bash/ksh/zsh, I would navigate back to command 74 then hit Control-O on each command to execute it and continue with the next. In vi mode I can navigate back to command 74 readily enough, but how do I then execute it and see command 75?

share|improve this question

2 Answers 2

Press <esc>, then 'k' until you get to the one you want, or something like '7k' if you know how many back, then enter to execute.

share|improve this answer
    
I will learn to count how many times I type 'k' getting back to (in my example) command 74, then type '16k' to get to command 75 and again for command 76 &c. Thanks. –  James Mar 8 '10 at 23:25

Try this:

set -o emacs

You may be in vi mode. You can add the line above to your ~/.profile file.

Or you can add the following to your ~/.kshrc file:

: ${EDITOR:=emacs}
share|improve this answer

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.