Terminal 里面的隐藏快捷键去哪看?

2016-05-23 23:34:00 +08:00
 hukangha
刚找一个功能好久 ( 删除整句命令 ),最终找到一些快捷键,但是这些都不在菜单里,那么像这种快捷键一般去哪里看呢?或者说这些快捷键不属于 Termianl 而属于 shell 程序?

Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let ’ s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
3064 次点击
所在节点    macOS
21 条回复
Citrus
2016-05-24 00:20:50 +08:00
你发的这些都不是 Terminal 的快捷键,而是 Bash 的快捷键。具体叫什么不记得了,等楼下科普。
cxbig
2016-05-24 00:30:10 +08:00
这些快捷键是 bash 默认的 emacs 模式快捷键
shell 默认是 emacs 模式,可以通过 set -o vi 切换到 vi 模式
相对的快捷键都是基于这 2 个编辑器的操作习惯定的
SharkIng
2016-05-24 02:18:16 +08:00
长按 CMD ?
Iblard
2016-05-24 08:11:42 +08:00
@Citrus 所有使用了 readline 库的都支持这个。
Iblard
2016-05-24 08:12:08 +08:00
aheadlead
2016-05-24 08:20:07 +08:00
readline 的文档里面有详细记载

这快捷键还是挺棒的,如打了这样一串命令

$ ping dns.v2ex.com

想改成

$ ping dns.baidu.com

可以这么按

<esc> 2
<esc> <c-]> .
<c-k> .baidu.com
harry890829
2016-05-24 08:31:47 +08:00
阿西吧,我还以为什么呢,作为一个 vim 党,我还真把 shell 改为 vi 模式用过,感觉非常难用……最后还是用了 emacs 模式,也就那几个常用的,稍微记一下就好了
Citrus
2016-05-24 09:15:36 +08:00
@Iblard 哦对就是这个! readline !
falcon05
2016-05-24 09:21:16 +08:00
stty -a
lizheming
2016-05-24 09:23:53 +08:00
推荐一个应用 CheatSheet 长按 Command 即可看当前程序的所有快捷键→_→
aaronzjw
2016-05-24 09:57:08 +08:00
Dash 可以看 iterm 的快捷键
lululau
2016-05-24 10:20:15 +08:00
zander
2016-05-24 13:22:21 +08:00
realline.
superbear
2016-05-24 13:33:02 +08:00
用 emacs 吧,它能让你更好地使用 linux 。很多快捷键和 Terminal 相同
julyclyde
2016-05-24 16:33:34 +08:00
@Citrus 不是 bash 的,而是 readline 的
lightening
2016-05-24 16:51:23 +08:00
这当中有一部分 Mac 全局都能用。
znoodl
2016-05-24 17:38:49 +08:00
其实就是 bash 的 emacs 模式
ghostheaven
2016-05-24 18:01:49 +08:00
搭车问, zsh 也用了 readline 么
hukangha
2016-05-24 23:11:42 +08:00
@Iblard 学到新东西了
netabare
2016-05-25 17:27:42 +08:00
@lizheming 然而对终端机里面的 shell 没用……

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/280782

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX