Operating System - HP-UX
1830732 Members
1889 Online
110015 Solutions
New Discussion

Using Arrow keys to view previous commands in a bourne shell

 
SOLVED
Go to solution
Kirill Cherkashin
Frequent Advisor

Using Arrow keys to view previous commands in a bourne shell

Hi,

I'm trying to set arrow keys for bourne-like shell. People told that i need to add next lines in my .shrc(or .kshrc)

HISTFILE = $HOME/.sh_history
histsize =512
set -o emacs
alias __A = ^P
alias __B = ^N
alias __C = ^F
alias __D = ^B

I did it.But it doesn't work for me. What's wrong? Do i need to adjust also in some way my terminal settings?
6 REPLIES 6
RikTytgat
Honored Contributor

Re: Using Arrow keys to view previous commands in a bourne shell

Hi,

What shell are you using? Bourne shell has no command line history.

On HP-UX, the /usr/bin/sh binary is a POSIX compliant shell (like ksh).

Bye,
Rik
Kirill Cherkashin
Frequent Advisor

Re: Using Arrow keys to view previous commands in a bourne shell

Yes,of course, I'm using posix compliant bourne shell.;-)
John Palmer
Honored Contributor

Re: Using Arrow keys to view previous commands in a bourne shell

Hi,

If you are using a terminal emulator like Reflections then you can map the keyboard for emacs edit mode...
up arrow sends CTRL/P,
down arrow sends CTRL/N,
left arrow sends CTRL/B
right arrow sends CTRL/F.

Regards,
John
RikTytgat
Honored Contributor
Solution

Re: Using Arrow keys to view previous commands in a bourne shell

Hi,

Try this:

# vi /tmp/emacsalias
alias __A=^P
...


BUT: To enter the '^P' use the keystrokes -v-p

This enters a control character into the file. Do the same for the other aliases.

Finally, source in your file:
. /tmp/emacsalias

And all should work!! (I tried it and OK)

Bye,
Rik
Kirill Cherkashin
Frequent Advisor

Re: Using Arrow keys to view previous commands in a bourne shell

I'm using putty as my terminal emulator. Though,I think it's not very important. As terminal settings I mean mostly some fancy stty options .
Kirill Cherkashin
Frequent Advisor

Re: Using Arrow keys to view previous commands in a bourne shell

Rik,

it works! but i put it directly to .shrc file.

Many thanks,

Kirill