Operating System - HP-UX
1755065 Members
3678 Online
108829 Solutions
New Discussion юеВ

Short cuts in HP-UX 11.00 - with question!

 
SOLVED
Go to solution
Simon R Wootton
Regular Advisor

Short cuts in HP-UX 11.00 - with question!

I'm wanting to switch on the functionality whereby the last used commands are displayed acting as shortcuts to typing command lines in again. How do I do this ?? Pls help.
7 REPLIES 7
Christopher McCray_1
Honored Contributor

Re: Short cuts in HP-UX 11.00 - with question!

make sure you have a .sh_history file and that in your .profile you have the following:


HISTFILE=$HOME/.sh_history
export HISTFILE

Hope this helps

Chris
It wasn't me!!!!
Carsten Krege
Honored Contributor

Re: Short cuts in HP-UX 11.00 - with question!

You need the following entries in your $HOME/.profile file (when using /usr/bin/sh, ksh or /sbin/sh as a shell):

HISTFILE=$HOME/.sh_history
export HISTFILE
set -o vi

Carsten



-------------------------------------------------------------------------------------------------
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move. -- HhGttG
Christopher McCray_1
Honored Contributor

Re: Short cuts in HP-UX 11.00 - with question!

I forgot the set -o vi line. Thanks, Carsten, good catch!!!!
It wasn't me!!!!
Tim D Fulford
Honored Contributor

Re: Short cuts in HP-UX 11.00 - with question!

Further to the above, you need to have your shell as /usr/bin/ksh or /usr/bin/sh.

Tim
-
Sanjay_6
Honored Contributor

Re: Short cuts in HP-UX 11.00 - with question!

Hi,

you can use this if you want.

set your EDITOR to "vi" if it is not already done through your profile.
EDITOR=vi
export EDITOR

then use

ksh -o vi

this will create a file .sh_history in your home directory if it is not available and will use one if it is already available. After this you can use k,l,j, and h for navigation through your earliar commands.

Hope this helps

Thanks
Bill Hassell
Honored Contributor
Solution

Re: Short cuts in HP-UX 11.00 - with question!

The command history is always enabled in the Korn shell (ksh) but must be explicitly enabled for the POSIX shell (part of the extra security found in /usr/bin/sh and /sbin/sh). Only one entry needs to be added to /etc/profile:

export HISTFILE=$HOME/.sh_history

Then logout and back in again. If .sh_history does not exist (primarily for root), you may have to create it using the touch command:

touch $HOME/.sh_history

Actually, only a single ESC is neede to recall the last command as in: ESC k

Some really useful command recall features:

Search for a particular command:
ESC / (search backwards for a string)

then after the first occurance of the search is found, use the letter n to move to the next one just like vi).

Recall a specific command:
history (that's an alias for fc -l)
or
history -100 (show the last 100 entries)

To recall a specific command:
r 123

You can edit a recalled command using most of the vi line edits and once the line is correct, press return to execute.

See the man page for sh-posix


Bill Hassell, sysadmin
Wodisch
Honored Contributor

Re: Short cuts in HP-UX 11.00 - with question!

Hello Simon,

and if you add "set -o viraw" after the
"set -o vi" you do get the Filename Completion
feature when you press after the
first few characters of a filename...

HTH,
Wodisch