[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to repeat a last command



What shell are you using?  What editor are you using for command-line
(e.g. vi or emacs)?

I use the Kornshell and vi.  In OpenBSD I use Kornshell and
vi-esccomplete for the editor.  It gives me the flexibility I'm used
to (command completion by hitting ESC twice) and I'm comfortable using
vi on the command-line.  But, I digress.

If you're comfortable with vi, you can set it as your command-line
editor and then use all the vi commands to search through your history
file from the command-line.  For example, to repeat the last command
hit ESC then k.  This scrolls up through your history file from the
last command to the first command.

Another thing you can do is search through the history file using /
(forward slash).  If you've executed a command awhile ago and you
don't want to retype it, search through your history file for it by
hitting ESC to get into command mode and typing / <expression>.  For
example, hitting ESC and typing /mount will search through your
history file for any occurrences of the word mount.  Then you can use
the n key to go to the next occurrence.

Of course, I only have experience with vi and the snippet from my
.kshrc file below will only show you how I'm setting the command-line
editor for the Kornshell, but this will give you an idea.  Your
mileage may vary.

rvb


###############################
# set the editor variable
# which is used by other programs
###############################
EDITOR=vi-esccomplete
export EDITOR

###############################
# set the command-line editor
###############################
set -o vi-esccomplete




"f980215" <f980215@mailandnews.com> wrote:

>hi,all
>
>I install openbsd v3.1 (using ps/2 keyboard )
>
>When keyboard input, how to repeat a last command on the console.
>
>thanks
>
>f980215


--
 ** remove "nospam." from the reply-to address to reach me via email **

 Do all your work as if you had a thousand years 
 to live, and as you would if you knew you must 
 die tomorrow. -Shaker Saying