Operating System - HP-UX
1753513 Members
5174 Online
108795 Solutions
New Discussion юеВ

Re: esc-k and similar commands

 
SOLVED
Go to solution
Eric Bakken
Regular Advisor

esc-k and similar commands

I have been using the esc-k and esc esc to put in commands and use command editing in hp-ux but never had to set it up... now on my workstation at home, it's not set up and i cant figure out what i have to do to set it up. I cant stand having to retype commands when i screw up, someone please help,

-Eric
7 REPLIES 7
Pete Randall
Outstanding Contributor
Solution

Re: esc-k and similar commands

In your profile/.rc file, etc., put the following:

HISTORY=$HOME/.history
set -o vi

That should do it.


Pete

Pete
RAC_1
Honored Contributor

Re: esc-k and similar commands

You need to have HISTFILE and HISTSIZE set in your profile.

HISTFILE=~/.sh_history
HISTSIZE=1000

This wuold store your commands in .sh_history file in your home dir and will store 1000 commands.

There is no substitute to HARDWORK
John Dvorchak
Honored Contributor

Re: esc-k and similar commands

The problem probably is that you have no history setup in your $HOME/.profile

Try something like this:

HISTFILE=$HOME/.sh_$LOGNAME
HISTSIZE=10000
export HISTFILE; export HISTSIZE


also don't forget to set your editor in the .profile:

# Set up the shell variables:
EDITOR=vi
export EDITOR


If it has wheels or a skirt, you can't afford it.
Marvin Strong
Honored Contributor

Re: esc-k and similar commands

you should read the manpage for your shell.
beit ksh or sh.

You need to setup your environment.

when reading the manpage pay attention to

HISTFILE
and
EDITOR

Bill Hassell
Honored Contributor

Re: esc-k and similar commands

There are two minimum requirements to enable the shell command history and recall: set the HISTORY variable to point to your shell's history file ($HOME/.sh_history by default) and also set the EDITOR variable to /usr/bin/vi to make sure the shell use vi syntax for recall and editing. There is one additional requirement for root: the $HISTORY must exist before it will be used. This apparently is not true for ordinary users. As root, just do this:

touch $HOME/.sh_history

The HISTSIZE variable is optional but allows you to limit/expand the maximum size of the history file. Manipulating the history file is done with fc commands but most people never use fc directly. Instead, aliases are created such as:

history='fc -l'
r='fc -e -'

I don't like typing much so I alias

h='fc -l'

and also have an hgrep alias:

hgrep='fc -l | grep -i'


Bill Hassell, sysadmin
Cem Tugrul
Esteemed Contributor

Re: esc-k and similar commands

Eric,

an example from my root .profile as below;

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

Good Luck,
Our greatest duty in this life is to help others. And please, if you can't
Eric Bakken
Regular Advisor

Re: esc-k and similar commands

thanks everyone, i got it working...