Operating System - HP-UX
1832484 Members
2762 Online
110043 Solutions
New Discussion

Re: Up Arrow fro Command Recall

 
Jeanine Kone
Trusted Contributor

Up Arrow fro Command Recall

Can anyone tell me how to get the up arrow key to work for command recall?
11 REPLIES 11
Herve BRANGIER
Respected Contributor

Re: Up Arrow fro Command Recall

Hi

Don't know how to use arrows to recall commands
but if you work in ksh you can use "Esc -" and
"Esc +" (don't forget to source your .profile
at login, with dtlogin, ie CDE environment, you
have to uncomment last line in .dtprofile :
SOURCEPROFILE=..)

HTH

Herv?

Sanjay_6
Honored Contributor

Re: Up Arrow fro Command Recall

Hi,

You can try this.
type ksh -o vi once you have logged in. It will create a history file .sh_history in your home directory. This file stores the command you type after ksh -o vi and will store till you exit from the shell by pressing cntl+D or exit.
to move to previous command you use the vi navigation keys k & j for moving up and down. press Esc and k to go to previous command and keep pressing k till you come to the command you are looking for. You can modify the command in the manner you modify a vi script. See if this helps. I'm doubtful you can use arrow keys to navigate. But others might be able to help on that. keep your fingers crossed.
Robin Wakefield
Honored Contributor

Re: Up Arrow fro Command Recall

I believe "bash" has this feature.

Robin.
Sachin Patel
Honored Contributor

Re: Up Arrow fro Command Recall

Hi Jeanine,
tcsh has this feature.
or try to add this line in your .login file.
setenv EDITOR emacs
logout and logback in.

Sachin
Is photography a hobby or another way to spend $
Laurent Paumier
Trusted Contributor

Re: Up Arrow fro Command Recall

I think emacs mode uses CTRL- combinations : ^P for previous line, ^N for next line, ^B for backward, ^F for forward... much more intuitive than vi mode ;)
Celso Medina Kern
Trusted Contributor

Re: Up Arrow fro Command Recall

Hello,

If you-re in posix or ksh shells, you can set them to recall your last commands using vi shortcuts ESC-K ESC-J and use vi commands to modify and execute them.

If you really want to use arrows, you need to download another shell not built in nor supported in hp-ux, bash shell:
http://hpux.connect.org.uk/hppd/cgi-bin/search
look for bash.
bash-2.05 (4 May 2001)

Best regards
God bless pessimists, they did the backup!
Steve Post
Trusted Contributor

Re: Up Arrow fro Command Recall

The up arrow key is usually escape[A.
You can find out by using vi on a bogus file.
"vi myfile"
Type :no beautify
Hit "i" for insert, hit control-V, then hit the up arrow. If you see ^[[A, your up arrow is ^[ <--what escape looks like on the screen.
[A <-- the rest of the text.

Now how do you get this to alias to escape-K? I dunno.


Jack Werner
Frequent Advisor

Re: Up Arrow fro Command Recall

I have been able to get my Arrows to work with the following:
1) My default shell is /usr/bin/ksh
2) In my .profile I have the following:
.
.
alias -x __A'^P' # Aliases up arow to Ctl P
alias -x __B'^N' # Aliases down arrow to Ctl N
alias -x __C'^F' # Aliases right arrow to Ctl F
alias -x __D'^B' # Aliases left arrow to Ctl B
alias -x __H'^A' # Aliases home key to Ctl A
set -o emacs # emacs control squences to edit cmds
.
.
3) I am using fvwm and set TERM=xterm
Good luck
i'm retired
Steve Post
Trusted Contributor

Re: Up Arrow fro Command Recall

I keep coming back here to find the answer for ME. Deciding to use a different shell is not the answer I'm looking for. But that's ok. I'm not the author anyway.

Jack Werner, I tried your alias command, but the syntax bombed out on me. I don't want to use emacs because I like vi too much (believe or not). The -x is not listed in the alias man page. We're talking hp here right?

anyway I type.
alias 'control-v' 'control-vk'
I get ^[[A: Invalid alias name.
Is there a special name for the up arrow for alias command?

I know buried in the termcap would be the definition that says to type [A when the up arrow is hit. (But you would not want to mess with that. You fix the up arrow key for command line editing, and break all of your applicatons).
Jeanine Kone
Trusted Contributor

Re: Up Arrow fro Command Recall

Well, I've got a lot of responses so far. Unfortunately none of them seem to hit the mark just yet. I am using the default shell(POSIX - in /usr/bin/sh - really just like the korn shell) in HP-UX 11. I am not up for changing to a different shell.

I am able to get the ctrl-p and cntl-n to work (and also the esc sequences if I change to vi mode), but I really want the actual arrow keys.

It looks like the last suggestion about aliasing the keys might be promising, but I think I'll need a bit more help getting it to work. Steve, did you have any luck?

Thanks fro all the suggestions, Jeanine
Steve Post
Trusted Contributor

Re: Up Arrow fro Command Recall

Sorry I did not respond back. I set this to give me notification of change in the forum, (but it didn't).
No. I have not been working on it lately.
I could not get the alias command to take goofy escape sequences as an alias name. It considers the "text" a shell function. But the name escape[A is too strange.

But I should tell about an obvious way around the problem I used before. Modify the windows terminal emulator's keymap (IF you have that option).

One time I had users that insisted the "end" key is now called the "action" key for some old cobol thing running on a very old hp. I discovered the little bugger wanted to see "escape[escape\1". (nice huh?). I got the end key to work right by modifying the keymap of the Reflections emulator. If could have messed with termpcap. But that little tweek was FAR from standard.

Now reflections and tinyterm both have key mapping utilities. Those are the two I used in the past.

Steve