Make Arrow and delete keys work in KornShell command line

前端 未结 5 2091
猫巷女王i
猫巷女王i 2020-12-13 07:10

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 th

5条回答
  •  情书的邮戳
    2020-12-13 07:51

    For the arrow keys, you can put this into your the .kshrc file in your home directory:

    set -o emacs
    alias __A=`echo "\020"`     # up arrow = ^p = back a command
    alias __B=`echo "\016"`     # down arrow = ^n = down a command
    alias __C=`echo "\006"`     # right arrow = ^f = forward a character
    alias __D=`echo "\002"`     # left arrow = ^b = back a character
    alias __H=`echo "\001"`     # home = ^a = start of line
    alias __Y=`echo "\005"`     # end = ^e = end of line
    

    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)

    echo "\020"
    

    to get the control-n character assigned to __B.

提交回复
热议问题