- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Cursors to navigate the ksh command history
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 02:19 AM
09-07-2006 02:19 AM
is there a way to set vi options in the ksh (set -o vi)
to use cursors to navigate the command history ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 10:06 AM
09-07-2006 10:06 AM
Re: Cursors to navigate the ksh command history
export HISTFILE=$HOME/.sh_history
export HISTSIZE=1000
set -o vi
Depending on how you setup ksh, you may be using .profile or .kshrc for your local profile. Once set, you can view your history with the history command, recall the last command with ESC k or search backwards with ESC /.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 10:19 AM
09-07-2006 10:19 AM
Re: Cursors to navigate the ksh command history
Once HISTFILE and HISTSIZE are set you merely hit escape k to go back through history.
There is a command called hist that lets you see and even filter output as well.
Note that HP-UX does not work very well with HISTFILE on NFS.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 07:59 PM
09-07-2006 07:59 PM
Re: Cursors to navigate the ksh command history
I know ESC k
I meant cursors keys -instead- of ESC k
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 10:55 PM
09-07-2006 10:55 PM
Re: Cursors to navigate the ksh command history
h - left
l - right
x - delete
a - append
i - insert
For more use vim help.
;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 11:35 PM
09-07-2006 11:35 PM
Re: Cursors to navigate the ksh command history
can you replace
h with cursor key "<-"
l with "->"
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 01:47 AM
09-08-2006 01:47 AM
Re: Cursors to navigate the ksh command history
This is from the book "Learning the Korn Shell 2nd edition" published by O'Reilly which quotes "The New KornShell Command and Programming Language" published by Prentice Hall.
It only work with KornShell 93 (/usr/dt/bin/dtksh for instance)
These are the lines to enter either in your .profile or at the shell prompt if you want to test it before :
typeset -A Keytable
trap 'eval "${Keytable[${.sh.edchar}]}"' KEYBD
function keybind # key [action]
{
typeset key=$(print -f "%q" "$2")
case $# in
2)
Keytable[$1]=
=' .sh.edchar=${.sh.edmode}'"$key"
;;
1)
unset Keytable[$1]
;;
*)
print -u2 "Usage: $0 key [action]"
return 2 # usage errors return 2 by default
;;
esac
}
Then call the keybind function with arguments that depend on your keyboard settings for the cursor keys. Mine is a PC under MS Windows.
Thus :
- the up arrow key sends ESC[A,
- the down arrow key sends ESC[B,
- the right arrow key sends ESC[C
- the left arrow key sends ESC[D
So I executed the keybind function with the following arguments :
keybind $'\E[A' k
keybind $'\E[B' j
keybind $'\E[C' l
keybind $'\E[D' h
I acknowledge that the code is tricky and I did not understand everything.
Best regards,
JPH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 01:52 AM
09-08-2006 01:52 AM
Re: Cursors to navigate the ksh command history
Keytable[$1]=' .sh.edchar=${.sh.edmode}'"$key"
There are no two = and it's all on the same line
Best regards,
JPH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 02:43 AM
09-08-2006 02:43 AM
Re: Cursors to navigate the ksh command history
# kill -l
1) HUP 16) USR1 31) RESERVED
2) INT 17) USR2 32) DIL
3) QUIT 18) CHLD 33) XCPU
4) ILL 19) PWR 34) XFSZ
5) TRAP 20) VTALRM 35) bad trap
6) IOT 21) PROF 36) bad trap
7) EMT 22) POLL 37) RTMIN
8) FPE 23) WINCH 38) RTMIN+1
9) KILL 24) STOP 39) RTMIN+2
10) BUS 25) TSTP 40) RTMIN+3
11) SEGV 26) CONT 41) RTMAX-3
12) SYS 27) TTIN 42) RTMAX-2
13) PIPE 28) TTOU 43) RTMAX-1
14) ALRM 29) URG 44) RTMAX
15) TERM 30) LOST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 02:55 AM
09-08-2006 02:55 AM
Re: Cursors to navigate the ksh command history
The trap KornShell built-in does not only catch signals. It can also catch some events like :
- the exit from the shell ( trap command EXIT)
- an error ( trap command ERR )
- the end of a command ( trap command DEBUG )
- a key stroke ( trap command KEYB )
This last event is a KornShell 93 feature not a KornShell 88 nor a POSIX shell (to my knowledge).
If you want to run a KornShell 93 on HP-UX execute /usr/dt/bin/dtksh.
Regards,
JPH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 04:13 AM
09-08-2006 04:13 AM
SolutionAS far as using the arrow keys to navigate the command history, neither standard ksh or the POSIX shell can be configured to use these non-standard keys. Bash has this capability but you would have to download and build it on your system.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2006 06:43 AM
09-12-2006 06:43 AM
Re: Cursors to navigate the ksh command history
It may be worth glancing at ksh93 features. You probably won't even have to download anything as /usr/dt/bin/dtksh is a ksh93.
Trap does not only catch signals it also intercepts events as I mentionned it previously.
Regards,
JPH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2006 08:24 PM
09-12-2006 08:24 PM