使箭头和删除键在KornShell命令行中起作用 [英] Make Arrow and delete keys work in KornShell command line

查看:67
本文介绍了使箭头和删除键在KornShell命令行中起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Unix的新手,正在使用sun solaris(我认为是v10).我将我的shell设置为KornShell(ksh).

I am new to Unix and am using sun solaris (v10 I think). I have my shell set as KornShell (ksh).

我想知道如何在命令行中使用箭头键和删除键.我已经完成了-o emacs的set和backspace的工作,但是没有完成箭头键和Delete键的设置.

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?

推荐答案

对于箭头键,您可以将其放入主目录中的.kshrc文件中:

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

请注意,等号左侧的字母前面有两个下划线字符.在等号的右侧,目标是获得分配给别名的正确控制字符.该脚本执行此操作的方式是通过运行命令(通过back-tics)

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"

获取分配给__B的control-n字符.

to get the control-n character assigned to __B.

这篇关于使箭头和删除键在KornShell命令行中起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆