I am new to Unix and am using sun solaris (v10 I think). I have my shell set as KornShell (ksh).
I am wondering how to make the arrow keys and delete key work in the command line. I have done set -o emacs and the backspace works, but not the arrow keys and the delete keys.
Also is it possible to set the up and down arrow key to cycle through the command line history?
Don't fight it. Just have your administrator change your default shell to bash. bash is included with Solaris 10, is highly ksh compatible, and it supports the key mappings that you like. You can launch bash just by typing:
You could exec bash out of your .profile if your administrator is not helpful. Here is what your administrator would do to change user1 to bash (as root):
For the arrow keys, you can put this into your the .kshrc file in your home directory:
Note that there are two underscore characters before the letters on the left side of the equal sign. On the right-hand side of the equal, the goal is to get the proper control character assigned to the alias. The way this script does that, is by running the command (via back-tics)
to get the control-n character assigned to __B.
I used following and is working fine:
Note: these are the actual control characters. In vi, type i ctrl-v then ctrl-P (if u want a ctrl-p)
and add below lines too:
Since it took me forever to figure out the delete key on my Mac, to get the delete key to work you can add
stty erase ^?
to your.kshrc
file. Instead of typing the actual characters for^?
you can just hit the delete key and it will output^?
. So in combination with Tim's answer my.kshrc
file looks likeThe default ksh might be ksh88 - which does not support the alias __ keyboard macros. Ksh93 does. Basically, if it doesn't work - you are probably using ksh88.