cancel
Showing results for 
Search instead for 
Did you mean: 

command history recall

SOLVED
Go to solution
Chris Conrad
Occasional Advisor

command history recall

I am trying to set up command history recall on my HP C3600 Worstations. When I type K to recall the previous command, all I see on the screen is ^[K. What do I need to set up to capture the ?
12 REPLIES
Robert-Jan Goossens
Honored Contributor

Re: command history recall

Hi,

add this to your profile

set -o vi
HISTFILE=$HOME/.sh_history
HISTSIZE=100

Robert-Jan.
RAC_1
Honored Contributor

Re: command history recall

recalling history is escape k/j
There is no substitute to HARDWORK
T G Manikandan
Honored Contributor

Re: command history recall

you have to use

#set -o vi
or
#ksh -o vi


THanks
Jose Mosquera
Honored Contributor

Re: command history recall

Hi,

Have you set in your user profile the followings statements?:

EDITOR=vi
export EDITOR

HISTFILE=/.sh_history; export HISTFILE
HISTSIZE=; export HISTSIZE

Where represent the number of commands lines stored in /.sh_history

And the correct way to invoke commands is by [Esc-Key] + K

Rgds
Chris Conrad
Occasional Advisor

Re: command history recall

everything is set up such that .sh_history captures the commands. The problem is..... that when i press the escape key, and then the "K" key, it simply shows up as ^[K instead of the previous command.
I have EDITOR=VI and set -o vi in my profile.
Please help
Robert-Jan Goossens
Honored Contributor

Re: command history recall

Hi,

here is a part of my /root/.profile

--cut----

# Be sure that VUE does not invoke tty commands

if [ ! "$VUE" ]; then

# -- Do trick to set the display in case of remote login
HOST=`who am i -R |awk '{print $NF}' | sed "s/(\(.*\))/\1/"`
if [ "$HOST" != "" ] && [ "$HOST" != ":0" ] && [ "$HOST" != ":0.0" ];
then
if [ "$HOST" = `who am i -R |awk '{print $NF}' | sed "s/(\(.*\))/\1/"` ]
then
HOST=$HOST:0.0
fi
echo " +--<<"
echo " | Remote login detected, setting DISPLAY to $HOST"
echo " +-->>"
DISPLAY=$HOST
export DISPLAY
fi

# Set up the terminal:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi
case `tty` in
*console*) TERM=hp ;;
*) TERM=vt100 ;;
esac
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty hupcl ixon ixoff
tabs

echo
echo "Value of TERM has been set to \"$TERM\". "
export TERM

EDITOR=vi
export EDITOR

fi # if !VUE

---cut----

try it.

Robert-Jan.
Jose Mosquera
Honored Contributor

Re: command history recall

Hi,

Maybe a terminal definition is involved, try setting your TERM=hp or TERM=vt100.

If this work, pls check your current stty assignament and compare it with your original TERM definiton.
#stty -a

Rgds.
John Jayaseelan
Super Advisor

Re: command history recall

Hi,

Trying the following shoud work.

set -o vi

or
EDITOR=vi
export EDITOR

Also set the history file size.

John Jayaseelan
harry d brown jr
Honored Contributor
Solution

Re: command history recall

Chris,

what does this return:

env | grep -i -e edit -e shell -e term -e hist

like this:

# env | grep -i -e edit -e shell -e term -e hist
EDITOR=vi
HISTFILE=/.sh_history
SHELL=/sbin/sh
HISTSIZE=50000
TERM=xterm
#


live free or die
harry
Live Free or Die
Chris Conrad
Occasional Advisor

Re: command history recall

Thanks Harry, with that suggestion, I was able to figure out the following:
EDITOR=/usr/dt/bin/dtpad.
But, EDITOR-vi is in my $HOME/.profile. So it doesn't appear that my .profile is being run, or else EDITOR is getting overwritten somewhere. Got any other suggestions?
Chris Conrad
Occasional Advisor

Re: command history recall

Follow-up. So I guess everyone was right, technically. As soon as I typed EDITOR=vi on the command line, it worked. But if I log out and log back in, it won't work anymore.
Danny Pogi
Advisor

Re: command history recall

you need to include those parameters that you change in your root's .profile file or in any other users profile.

here's how:

1. login as root

2. edit your .profile

# vi .profile

3. then add:

EDITOR=vi;export EDITOR
HISTFILE=/.sh_history
HISTSIZE=500
export HISTFILE HISTSIZE

4. save the file and exit

5. to test:

# /.profile

even when you logged out you should still have this profile as it is being hard coded in the root's profile.

that's it!

regards,
danny