**注意:我在SuperUser上问了同样的问题,但没有得到任何回应。我现在意识到这是一个针对此特定问题的更合适的论坛。*
在ksh shell中,Delete键在命令行上无法正常工作。当我按Delete时,我得到〜。
我如何能:
- 是否将“删除光标处的字符”功能绑定 到“删除键盘”按钮?(Control-D的行为类似于我期望的“删除”按钮,并且我尝试使用别名的尝试均未成功且可能很幼稚。)
- 将“ 移至行首 ”功能绑定到主键盘按钮?(控件A现在正在执行此操作,但我希望Home可以执行此操作。)
- 将“ 移至行尾 ”功能绑定到“结束 ”键盘按钮?(控件E现在执行此操作,但我想结束此操作。)
最终更新?
我偶然发现了一些行之有效的方法,但我不十分清楚为什么。这有效:
bind '^[[3'=prefix-2
bind '^[[3~'=delete-char-forward
根据http://www.qnx.com/developers/docs/6.3.2/neutrino/utilities/k/ksh.html#bind,
prefix-2
Key binding: ^X, ^[[
Introduces a 2-character command sequence.
所以我更新的问题是为什么我需要为此使用prefix-2
?请为我翻译,以便我能理解,因此我不必再为此烦人了。
旧工作流程
更新
事实证明QNX中的ESC是^[
。使用命令,bind '^[[3~'='delete-char-backward'
我能够使光标用覆盖光标下的字符~
。至少这是一些进步-我现在知道如何为Shell 拼写Delete Key。我在网上看到的大多数内容都说Delete键是^?
,但是这似乎对我不起作用。另外,我要提一下我正在通过PuTTy访问此文件。
我不明白,因为Control D会执行我希望删除键执行的操作。我试图eot-or-delete
再次将其绑定无济于事。
这应该很简单,对吧?
更新2:
bind | grep prefix
^X = prefix-2
^[ = prefix-1
ÿ = prefix-3
^[O = prefix-2
^[[ = prefix-2
bind | grep '[^ -~]'
ÿ = prefix-3
à = beginning-of-line
à¡ = up-history
ठ= backward-char
ঠ= forward-char
ਠ= end-of-line
à© = down-history
ଠ= delete-char-forward
à´ = backward-word
ච= forward-word
更新3:我的更多设置
ENV设定
echo $ENV
/etc/kshrc
绑定完成输出
bind
^A = beginning-of-line
^B = backward-char
^C = abort
^D = eot-or-delete
^E = end-of-line
^F = forward-char
^G = abort
^H = delete-char-backward
^I = complete
^J = newline
^K = kill-to-eol
^L = redraw
^M = newline
^N = down-history
^O = newline-and-next
^P = up-history
^R = search-history
^T = transpose-chars
^U = kill-line
^V = version
^W = kill-region
^X = prefix-2
^Y = yank
^[ = prefix-1
^\ = no-op
^] = search-character-forward
^^ = quote
^_ = eot
^? = delete-char-backward
ÿ = prefix-3
^[^H = delete-word-backward
^[^X = complete-file
^[^[ = complete
^[^] = search-character-backward
^[ = set-mark-command
^[# = comment
^[* = expand-file
^[. = prev-hist-word
^[0 = set-arg
^[1 = set-arg
^[2 = set-arg
^[3 = set-arg
^[4 = set-arg
^[5 = set-arg
^[6 = set-arg
^[7 = set-arg
^[8 = set-arg
^[9 = set-arg
^[< = beginning-of-history
^[= = complete-list
^[> = end-of-history
^[? = list
^[C = capitalize-word
^[L = downcase-word
^[O = prefix-2
^[U = upcase-word
^[[ = prefix-2
^[_ = prev-hist-word
^[b = backward-word
^[c = capitalize-word
^[d = delete-word-forward
^[f = forward-word
^[g = goto-history
^[h = delete-word-backward
^[l = downcase-word
^[u = upcase-word
^[y = yank-pop
^[^? = delete-word-backward
^X^X = exchange-point-and-mark
^X^Y = list-file
^X^[ = complete-command
^X? = list-command
^XA = up-history
^XB = down-history
^XC = forward-char
^XD = backward-char
^XH = beginning-of-line
^XP = delete-char-forward
^XY = end-of-line
^Xc = forward-word
^Xd = backward-word
^Xw = end-of-line
à = beginning-of-line
à¡ = up-history
ठ= backward-char
ঠ= forward-char
ਠ= end-of-line
à© = down-history
ଠ= delete-char-forward
à´ = backward-word
ච= forward-word
/ etc / kshrc
/etc # cat kshrc
case $- in
*i*)
export SHELL_COLOR_BLUE="print -n \\033[0;34m"
export SHELL_COLOR_GREEN="print -n \\033[0;32m"
export SHELL_COLOR_RED="print -n \\033[0;31m"
export SHELL_COLOR_LIGHTGRAY="print -n \\033[0;37m"
export SHELL_COLOR_YELLOW="print -n \\033[1;33m"
export COLOR_BLACK="\\033[0;30m"
export COLOR_BLUE="\\033[0;34m"
export COLOR_GREEN="\\033[0;32m"
export COLOR_CYAN="\\033[0;36m"
export COLOR_RED="\\033[0;31m"
export COLOR_PURPLE="\\033[0;35m"
export COLOR_BROWN="\\033[0;33m"
export COLOR_LIGHTGRAY="\\033[0;37m"
export COLOR_DARKGRAY="\\033[1;30m"
export COLOR_LIGHTBLUE="\\033[1;34m"
export COLOR_LIGHTGREEN="\\033[1;32m"
export COLOR_LIGHTCYAN="\\033[1;36m"
export COLOR_LIGHTRED="\\033[1;31m"
export COLOR_LIGHTPURPLE="\\033[1;35m"
export COLOR_YELLOW="\\033[1;33m"
export COLOR_WHITE="\\033[1;37m"
if [[ `id -u` -eq 0 ]]; then
export PS1=`$SHELL_COLOR_RED`'$(hostname -s):'`$SHELL_COLOR_YELLOW`'$(pwd) # '`$SHELL_COLOR_LIGHTGRAY`
else
export PS1=`$SHELL_COLOR_BLUE`'$(hostname -s):'`$SHELL_COLOR_GREEN`'$(pwd) $ '`$SHELL_COLOR_LIGHTGRAY`
fi
esac
PuTTy设定:
可能重要或不重要但可能提供背景的注释:
外壳为“ PD KSH v5.2.14 99/07 / 13.2”。是的,我没有升级的选择……这是一个嵌入式系统。“获得现代的外壳”不是一个可行的答案。操作系统是QNX Neutrino 6.4.1。
绑定显示以下内容:
bind | grep del
^D = eot-or-delete
^H = delete-char-backward
^? = delete-char-backward
^[^H = delete-word-backward
^[d = delete-word-forward
^[h = delete-word-backward
^[^? = delete-word-backward
^XP = delete-char-forward
ଠ= delete-char-forward
infocmp显示以下内容:
infocmp # Reconstructed via infocmp from file:
/usr/lib/terminfo/x/xterm xterm|vs100|xterm terminal emulator,
am, km, mir, msgr, xenl, xon,
cols#80, it#8, lines#65, vt@,
acsc=Oa``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
bel=^G, blink=@, bold=\E[1m, clear=\E[H\E[2J, cr=^M,
csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
el=\E[K, el1=\E[1K$<3>, enacs=\E(B\E)0, home=\E[H, ht=^I,
hts=\EH, ich=\E[%p1%d@, ich1=\E[2~, il=\E[%p1%dL, il1=\E[L,
ind=^J, is1=\E=\E[?1l, kBEG=\ENn, kCPY=\ENs, kCRT=\ENt,
kDL=\ENv, kEXT=\ENw, kFND=\ENx, kHLP=\ENy, kOPT=\ENz,
ka3=\EOs, kb2=\EOr, kbs=^H, kc1=\EOq, kcan=\EOm, kclo=\ENc,
kclr=\ENa, kcmd=\EOu, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
kcuu1=\E[A, kdch1=\E[P, kend=\E[9, kf1=\E[11~, kf10=\E[21~,
kf11=\E[23~, kf12=\E[24~, kf2=\E[12~, kf3=\E[13~,
kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~,
kf9=\E[20~, kfnd=\ENf, khlp=\ENh, khome=\E[8, khts=\ENb,
kich1=\E[2~, kmov=\ENi, kmrk=\ENm, kmsg=\ENe, knp=\E[6~,
kopn=\ENo, kopt=\ENk, kpp=\E[5~, kref=\ENl, kres=\ENp,
krfr=\ENg, krpl=\ENr, krst=\ENj, ksav=\ENq, kslt=\EOM,
ktbc=\ENd, kund=\ENu, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
rmam=\E[?7l, rmkx=\E>, rmso=\E[m,
rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, rs2=@,
sc=\E7,
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m,
sgr0=\E[m, smacs=^N, smam=\E[?7h, smkx=\E=, smso=\E[7m,
tbc=\E[3g,
stty显示以下内容:
stty Name: /dev/ttyp0 Type: pseudo Opens: 2
+edit +echok +echonl
+osflow intr=^C quit=^\ erase=^? kill=^U eof=^D start=^Q stop=^S susp=^Z lnext=^V min=01 time=00 pr1=^[ pr2=5B left=44 right=43
up=41 down=42 ins=40 del=50 home=48 end=59
kshrc
为无济于事。我得到 sh: /etc/kshrc[21]: trap: bad signal KEYBD
我没有另一个shell选项很遗憾。我不知道这是PDKSH还是QNX或两者都有问题。我知道哪种键组合会导致我想要的东西。我只需要知道将它们映射到适当键的语法即可。
bind | grep prefix
显示你?还有bind | grep '[^ -~]'
呢
bind '^[[3~'='delete-char-forward'
应该已经起作用。我不明白那些非ASCII字符来自哪里(它们不是第8位设置的ESC + foo序列,也不是latin1 / utf8的混淆)。'bind'^ X3〜= delete-char-forward'是否有效?