Operating System - HP-UX
1753449 Members
6121 Online
108794 Solutions
New Discussion юеВ

Re: recall previous command using esc-k

 
SOLVED
Go to solution
Joy Conner
Advisor

recall previous command using esc-k

I have a unix system that does not recall previous commands. What setting do I need to change to enable this?
12 REPLIES 12
TwoProc
Honored Contributor

Re: recall previous command using esc-k

If it's a Linux box using bash, or another Unix using ksh.

set EDITOR=vi
set -o vi


Try the above without the first line, if it works, great. If not, try it again with the set EDITOR command. If you need both, there's your fix.

If it's bash your using then the default history recall command is ctrl-r. The above changes it to act like ksh.
We are the people our parents warned us about --Jimmy Buffett
Joy Conner
Advisor

Re: recall previous command using esc-k

This did not work.

The system is HPUX B.11.00 and the user is root.
TwoProc
Honored Contributor
Solution

Re: recall previous command using esc-k

type ksh
then try your esc-k commands, if it doesn't work, then try:
set -o vi
then try your esc-k commands, if it doesn't
work, then try
set EDITOR=vi; export EDITOR (export shouldn't be necessary, but doesn't hurt).

Then try your esc-k commands, You should be working now.

FYI: as root, in the default posix shell, you generally don't have history turned on, check HISTSIZE.

echo $HISTSIZE

if this is zero, you don't have history. When you invoke ksh, you'll read the /etc/profile script, which by default has a HISTORY size setting, so this starts to work.

Alternately, you could just try setting HISTSIZE to something other than zero without using ksh. Then try esc-k,
then try setting "-o vi", then try esc-k, then try "set EDITOR=vi",then try esc-k.

When you've finally got a solution working, add the three "set" commands to your ~/.profile in your home directory, which is probably just "/", unless you've changed it.

put this in root's .profile, preferably at the end of the file.

set HISTSIZE=300
set EDITOR=vi
set -o vi

We are the people our parents warned us about --Jimmy Buffett
Joy Conner
Advisor

Re: recall previous command using esc-k

ksh worked. Thank you.

Does this mean that I need to remember to type this command when ever I want to recall?
Steven Schweda
Honored Contributor

Re: recall previous command using esc-k

> Does this mean that I need to remember to
> type this command when ever I want to
> recall?

If you wish to use command-line recall in a
shell, then you probably need to use a shell
which does command-line recall. If the
normal "root" shell doesn't do it, then you
might need to run some other shell, like,
say, "ksh" or "bash".

Changing the default "root" shell on an
HP-UX system is generally a very bad idea, so
you may be better off manually running the
other shell when you log into the HP-UX
system.
Joy Conner
Advisor

Re: recall previous command using esc-k

OK. Thank you for your help.
TwoProc
Honored Contributor

Re: recall previous command using esc-k

Joy, just add the commands into root's home directory in the file called .profile, it's probably at the top of the tree at "/.profile".

Put the three "set" commands there, and when you run "ksh" it will run the contents of the ".profile" file. Oh, yeah and make sure the file is executable for root: "chmod u+x .profile"

We are the people our parents warned us about --Jimmy Buffett
stephen peng
Valued Contributor

Re: recall previous command using esc-k

just enter ksh -o vi after you login
TwoProc
Honored Contributor

Re: recall previous command using esc-k

My mistake - while what I said will work - the better place to put the "set" commands would be in /.kshrc ; and then make it executable.
We are the people our parents warned us about --Jimmy Buffett