Operating System - HP-UX
1760365 Members
4000 Online
108893 Solutions
New Discussion юеВ

How to use "up" key to see previous issued commands insted of "Esc+K"?

 
SOLVED
Go to solution
Chia-Lin Mei
Occasional Contributor

How to use "up" key to see previous issued commands insted of "Esc+K"?

After export HISTFILE and HISTSIZE environment parameters, we could use "Esc+K" to see previous issued command. Is it possible for me to press "up" key instead of "Esc+K"? My shell is ksh.
ц╕мшйж
11 REPLIES 11
T G Manikandan
Honored Contributor

Re: How to use "up" key to see previous issued commands insted of "Esc+K"?

install bash shell,

you can use your arrow keys,

http://hpux.cs.utah.edu/hppd/hpux/Shells/bash-3.00.14/
Suraj Singh_1
Trusted Contributor

Re: How to use "up" key to see previous issued commands insted of "Esc+K"?

Are you talking of the functionality which bash shell provides?

May be you can copy the bash shell to your /bin directory and midify /etc/passwd to point to this shell.

Rgds
What we cannot speak about we must pass over in silence.
Naveej.K.A
Honored Contributor

Re: How to use "up" key to see previous issued commands insted of "Esc+K"?

Hi,

don't think its possible with the Posix Shell which is available in HPUX by default.

Linux has bash shell and supports the UP key.

Regards,
Naveej
practice makes a man perfect!!!
Steven E. Protter
Exalted Contributor

Re: How to use "up" key to see previous issued commands insted of "Esc+K"?

I once made this very same proposal to a HP Linux expert in a training class.

She was a very bright individual.

Her recommendation was remember when I switch between hp-ux and Linux.

If you use the bash shell on HP-UX you lose key features that you would expect on the OS. You CAN NOT change the root shell, so you have a hybrid situation anyhow.

bash is non-standard and if you ever want a vacation you should leave your HP-UX system in the way a backup our outside admin might expect to find it.

So, I recommend you not make this change.

You should be able to manipulate stty -a output to make this work with a termcap and TERM variable. A lot of work for little payoff.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Denver Osborn
Honored Contributor
Solution

Re: How to use "up" key to see previous issued commands insted of "Esc+K"?

Instead of using vi as your editor, use emacs. This can be added to your ~/.shrc (or whatever ENV= in your .profile)


Here's what to add... (man sh-posix or man ksh for details on emacs)

EDITOR=emacs
alias _A=^P
alias _B=^N
alias _D=^B
alias _C=^F
alias __A=^P
alias __B=^N
alias __D=^B
alias __C=^F


note that when you edit your .shrc, to get ^P you'l type ctrl-v then ctrl-p... same for ^N, ^B... etc...

When you logout/login you'll be able to use the arrow keys to recall previous cmds from your shell hist.

My login shell is posix, and I haven't tested w/ ksh... but I hope it would work just the same.

Hope this helps,
-denver
renarios
Trusted Contributor

Re: How to use "up" key to see previous issued commands insted of "Esc+K"?

Hi Chia,

Beside all great answers you already got, another possibility is to "learn vi and love it". Once you know the basic vi commands, you NEVER want to use another command line editor.
A great advantage of vi is that you can search in your history by typing: Esk+k
/

Cheers,

Renarios
Nothing is more successfull as failure
MAUCCI_2
Frequent Advisor

Re: How to use "up" key to see previous issued commands insted of "Esc+K"?

yes

as said denver, it is a matter of unix emacs editing mode properly configured.

it is not a matter of shell (bash vs others) but a matter of editing mode.

linux is easy because it uses a properly configured emacs ed mode in bash by default

-cyrille
Bill Hassell
Honored Contributor

Re: How to use "up" key to see previous issued commands insted of "Esc+K"?

The reason that the arrow keys are not easily implemented is that they are non-existant characters. There is no code in ASCII for the arrow keys, the page up/down key, Home/End keys, etc. Instead, these keys generate a keycode which is interpreted by the current application. This gets complicated because the keyboard might be on a 'real' terminal, a keyboard attached to a graphics HP-UX system, or most often, a PC keyboard. In each case, the action taken by the terminal or emulator depends on settings.

For a 'real' terminal, there may be an emulation setting (HP 700/9x series has HP as well as EM settings) as well as a local/remote execution option. For instance, when set to local execution, the arrow keys just move the cursor--the shell knows nothing about this action. In remote execution, the key is assigned a couple of characters, usually ESC plus one other character. So pressing up-arrow on an HP terminal produces ESC A (ESC B for down and so on). Now the application (in this case, the shell) must trap a 2-character sequence in order to respond in some way to the arrow keys. And of course, the application must turn on the remote execution of special keys (in HP terminals, called transmit functions, and in Curses, the rmkx and smkx codes). vi does this automatically which is why the arrow keys work in vi with HP terminals and the default .exrc file in $HOME.

It's a do-able feature but so far, the changes to the POSIX and Korn shells have not been made. You may want to talk to your HP sales rep about an enhancement request.


Bill Hassell, sysadmin
lawrenzo
Trusted Contributor

Re: How to use "up" key to see previous issued commands insted of "Esc+K"?

as renarios has mentioned:

esc +k then /

will display the latest command you are looking for ie.

you used a find string 10 commands previously:

esc +k then /find

this will display the last find command, if the command your searching is previous to this then press n key for the find command previous to that.

I know this doesn't answer your question however could prove useful if you continue to use the posix shell.
hello