如何更改终端字符编码

如何更改终端字符编码

今天我卸载了我的家庭 CentOS 安装上的 GUI 软件包。现在,当机器启动时,我收到登录提示。它的行为很挑剔。有时,在回答每个提示后只需按一次 Enter 键即可。其他时候,没有。当我成功登录时,我只能bash通过一次输入一个字符来输入命令 - 即:

l, enter
o, enter
c, enter
a, enter
l, enter
e, enter
enter

有人对此有一些见解吗?

更新:这是以下结果stty -a

speed 38400 baud; rows 64; columns 160; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts cdtrdsr
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

不过,任何不同的设置都不会stty sane产生影响。

答案1

编辑2:http://unixhelp.ed.ac.uk/CGI/man-cgi?stty 可以帮助了解 stty 输出。我会特别看看你的“min = 1”和不同的 echo* 设置

您可能希望尝试一些 stty 的调用(您的示例看起来有点像“stty cbreak”或“raw”模式)。尝试输入: stty sane

一旦修复(如果有效),您将可以更轻松地进行调查

Edit1:添加stty -a设置后,我将向您展示您的设置和我的设置之间的差异。

(请注意,我是在旧的 AIX xterm 上进行的,所以当然有很多差异!但它可以指出相关的差异...我让你做这项工作,看看哪个可能是罪魁祸首,因为我不知道现在有时间,抱歉!)

为此,我在“WELIST”中列出了 stty 向我们显示的所有关键字,然后在每个 stty 的每一行前面添加了一个“”,并用以下命令显示它们:

for i in $( cat WELIST) ; do
   I_Have=$(grep "[ -]$i " IHAVE)
   You_Have=$(grep "[ -]$i " YOUHAVE)
   if [ "$I_Have" = "$You_Have" ]
   then
      printf "%-20s : %s\n" "$I_Have"   "BOTH"
   else
      if [ -z "$I_Have" ]
      then
         printf "%-20s : %s\n" "$You_Have" "ONLY you"
         continue
      fi
      if [ -z "$You_Have" ]
      then
         printf "%-20s : %s\n" "$I_Have"   "ONLY me"
         continue
      fi
      printf "%-20s : %s\n" "$I_Have"   "me"
      printf "%-20s : %s\n" "$You_Have" "you"
   fi
done

它给出:

 brkint              : me
-brkint              : you
 bs0                 : ONLY you
 cdtrdsr             : ONLY you
-clocal              : BOTH
 179 columns         : me
 columns 160         : you
 cr0                 : ONLY you
 cread               : BOTH
-crtscts             : ONLY you
 cs8                 : BOTH
-cstopb              : BOTH
 discard = ^O        : ONLY me
 dsusp = ^Y          : ONLY me
 echo                : BOTH
-echoctl             : me
 echoctl             : you
-echoe               : me
 echoe               : you
-echok               : me
 echok               : you
-echoke              : me
 echoke              : you
-echonl              : BOTH
-echoprt             : BOTH
 eof = ^D            : BOTH
 eol = <undef>       : BOTH
 eol2 = <undef>      : BOTH
 erase = ^?          : BOTH
 eucw 1:1:0:0        : ONLY me
 ff0                 : ONLY you
 flush = ^O          : ONLY you
-flusho              : ONLY me
-hupcl               : me
 hupcl               : you
 icanon              : BOTH
 icrnl               : BOTH
-iexten              : me
 iexten              : you
-ignbrk              : BOTH
-igncr               : BOTH
-ignpar              : BOTH
-imaxbel             : BOTH
-inlcr               : BOTH
-inpck               : BOTH
 intr = ^C           : BOTH
 isig                : BOTH
-istrip              : BOTH
-iuclc               : BOTH
 iutf8               : ONLY you
-ixany               : BOTH
-ixoff               : BOTH
 ixon                : BOTH
 kill = ^U           : BOTH
 line = 0            : ONLY you
 lnext = ^V          : BOTH
 min = 1             : ONLY you
 nl0                 : ONLY you
-noflsh              : BOTH
-ocrnl               : BOTH
-ofdel               : BOTH
-ofill               : BOTH
-olcuc               : BOTH
 onlcr               : BOTH
-onlret              : BOTH
-onocr               : BOTH
 opost               : BOTH
-parenb              : BOTH
-parext              : ONLY me
-parmrk              : BOTH
-parodd              : BOTH
-pending             : ONLY me
 quit = ^\           : BOTH
 reprint = ^R        : ONLY me
 60 rows             : me
 rows 64             : you
 rprnt = ^R          : ONLY you
 scrw 1:1:0:0:       : ONLY me
 speed 38400 baud    : BOTH
 start = ^Q          : BOTH
 stop = ^S           : BOTH
 susp = ^Z           : BOTH
 swtch = <undef>     : ONLY you
 tab0                : ONLY you
 tab3                : ONLY me
 time = 0            : ONLY you
-tostop              : BOTH
 vt0                 : ONLY you
 werase = ^W         : BOTH
-xcase               : BOTH

相关内容