无法在终端中输入 'a' 符号

Can't type 'a' symbol in terminal

我的终端出现了奇怪的行为。我的 OS X 上的 iTerm 和基本终端都不起作用。我只能输入 'A' 而不是 'a',但不能输入 'a' 字母。如果我尝试 bash --noediting 然后我可以输入 'a' 但是使用起来很不舒服。我检查了我的 ~/.bashrc~/.bash_profile 并没有发现任何让我觉得奇怪的东西。谁能帮帮我? 任何反馈表示赞赏。

如果字母a已经映射到其中一个控制字符,你可以得到一些有趣的效果。试试 stty -a,除了你可能需要输入:

  • stty</code>、<code>-Control-V, a

获取命令的-a。这应该向您显示类似的内容:

speed 9600 baud; 65 rows; 135 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
    -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
    -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
    -ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
    eol2 = <undef>; erase = ^?; intr = ^C; kill = ^X; lnext = ^V;
    min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
    stop = ^S; susp = ^Z; time = 0; werase = ^W;

除了如果我的怀疑是正确的,cchars 值之一是 a

您很可能以某种方式为 a.

引入了 readline 绑定

作为第一步,试试这个:(grep 参数是 $"a",但你不能输入它:))

bind -p | grep $'"\x61"'

它应该打印这个:

"a": self-insert

如果是,那么我的猜测是错误的,你需要去别处看看。如果没有,那么你需要修复它,你可以这样做:

bind $'"\x61"':self-insert

现在您需要找到 bash 启动文件中不正确的 bind 命令所在的位置。我首先会搜索 bind。它很可能位于源自这些文件之一的文件中。祝你好运。

您还应该检查 readline 库用来初始化其绑定的文件 ~/.inputrc