• [转] linux下shell中使用上下键翻出历史命名时出现^[[A^[[A^[[A^[[B^[[B的问题解决,Linux使用退格键时出现^H解决方法


    [From]

    https://www.zmrbk.com/post-2030.html

    https://blog.csdn.net/suifengshiyu/article/details/40952771

    我的理解是,如果出现如题所描述的问题,这是因为使用了不同的shell程序和对应的stty设置对应关系所综合作用的结果。

    这是/bin/sh里面stty -a命令输出的信息:

    $ stty -a
    speed 38400 baud; rows 43; columns 209; 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; discard = ^O; min = 1; time = 0;
    -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
    -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 -flusho -extproc

    这是/bin/bash里面stty -a命令输出的信息,可以看到不同的字符映射:

    pekkle@PPLinux:~$ stty -a
    speed 38400 baud; rows 43; columns 209; line = 0;
    intr = ^C; quit = ^; erase = ^H; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
    -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
    -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 -flusho -extproc

    转发以上两篇文章,都是解决方法。简单的方法是用/bin/bash代替/bin/sh,在ubuntu里是正常的。

    linux下shell中使用上下键翻出历史命名时出现^[[A^[[A^[[A^[[B^[[B的问题解决

    今天在使用kali linux的时候,使用上下键想翻出历史命令时,却出现^[[A^[[A^[[A^[[B^[[B这种东东,而tab键补全命令的功能也无法使用。
    
    
    最终发现是由于当前用户使用的shell是/bin/sh的原因。
    
    useradd的时候没有指定用户的shell类型,因此默认为/bin/sh1:查看当前用户的shell类型命令: echo $SHELL
    
    2:改变当前用户登录默认的shell:chsh -s /bin/bash username  或者使用usermod -s /bin/bash username命令
    
    
    默认的shell改成/bin/bash之后正常了。
    
    bash和sh的区别:http://hi.baidu.com/aaronike/item/08cfca8ab2ca145d850fabd3
    
    sh其实是dbash的软连接。

    Linux使用退格键时出现^H解决方法

    以前在linux下执行脚本不注意输错内容需要删除时总是出现^H ,以前不知道真相的我没办法只有再重头运行一次脚本,后来发现其实时有解决办法的,所以记录一下。
    
    ^H不是H键的意思,是backspace。主要是当你的终端backspace有问题的时候才需要设置。
    
    解决方法有两种:
    1、要使用回删键(backspace)时,同时按住ctrl键
    2、设定环境变量
    在脚本的开头或结尾 参数 stty erase ^H stty erase ^?
    在bash下:$ stty erase ^?
    或者把 stty erase ^? 添加到.bash_profile中。
    在csh下:$ stty erase ^H
    或者把 stty erase ^H 添加到.cshrc中
  • 相关阅读:
    TIF转JPG
    跨线程取出控件的值的写法(不是跨线程赋予控件值)
    oracle根据正则表达式查找对应的字段
    oracle数据库连接字符串
    access检测表没有的字段,添加之
    解决 Unable to load DLL 'OraOps9.dll': 找不到指定的模块。 (Exception from HRESULT: 0x8007007E)
    oracle关键字使用
    to_number,Extract oracle的关键字
    OracleCommand.CommandText 无效
    调用带参数的线程两种方法
  • 原文地址:https://www.cnblogs.com/pekkle/p/8995723.html
Copyright © 2020-2023  润新知