Operating System - HP-UX
1753809 Members
8519 Online
108805 Solutions
New Discussion юеВ

"doskey" like keyboard function

 
D'Urso Joe
Occasional Contributor

"doskey" like keyboard function

I've seen other people hit some sequence of keys to get a history of commands
entered come up on at the prompt (sort of like DOSKEY).

Can someone PLEEEEEEZEE tell me how to do this ?
2 REPLIES 2
Neil Gast_1
Frequent Advisor

Re: "doskey" like keyboard function

The korn shell (my favorite) does this quite nicely. Put the following in
~/.profile:
set -o vi
alias r='fc -e -'
export HISTFILE="~/.sh_history"
export HISTSIZE=500 # or whatever

The key sequence is ESC then k. This puts you into your history mode, where you
can move back and forth using the j and k keys. You can also edit the command
like with vi commands.
The "alias r" is not really part of the history recall. It merely allows you to
type r to rerun the previous command in your history.

You can alternately use emacs editing mode if it's more familiar to you.

The bash shell will also do command history recall. Either case, you should
definately read the man page, as ksh is NOT standard across all
implementations.

MrNeil
Jason Luginbuhl_1
Frequent Advisor

Re: "doskey" like keyboard function

Joe,

This "command line history" is normally done via the -k functionality
built into the vi editor. For this to work the following has to be done. This
is normally done in the ~/.profile of the user in ksh and POSIX shell and it
.login of csh.

export EDITOR=vi
export HISTFILE=~/.sh_history
export HISTSIZE=200

The file .sh_history must reside in the home directory of the user. If it does
not exist then touch an empty file called .sh_history. Once this is setup you
should be able to type -K to bring up previous commands.

NOTE: There is a known problem with this in NFS mounted directories. Logins may
hang in that setup.