up vote 0 down vote favorite
share [g+] share [fb]

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?

link|improve this question
feedback

2 Answers

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.

link|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
feedback

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}
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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