加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

Shell自定义快捷键方法详解

发布时间:2020-12-14 02:16:57 所属栏目:Linux 来源:网络整理
导读:首先,我们要学会查看 Shell 中已有快捷键的方法,如下所示: [root@localhost ~]# stty -a #查询所有的快捷键 speed 38400 baud; rows 21; columns 1.04; line = 0; intr = ^C; quit = ^; erase = ^?; kill = ^U; eof = ^D; eol = undef; eol2 = undef; swt
首先,我们要学会查看 Shell 中已有快捷键的方法,如下所示:

[root@localhost ~]# stty -a
#查询所有的快捷键
speed 38400 baud; rows 21; columns 1.04; 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 nlO crO tabO bsO vtO ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke


"-a"选项用于査询系统中所有可用的快捷键,可以看到,"Ctrl+C"用于强制中止,"Ctrl+D"用于中止输入。那么,这些快捷键可以更改吗?

当然可以,只需执行以下命令即可:

[root@localhost ~] # stty 关键字 快捷键
例如:
[root01ocalhost ~]# stty intr ^p
#定义Ctrl +P快提键为强制中止,"^"字符只需手工输入即可
[root@localhost ~】# stty -a
speed 38400 baud; rows 21; columns 104; line = 0;
intr = ^P; 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;
#强制中止的快提键变成了Ctrl+P

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读