V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hukangha
V2EX  ›  macOS

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

  •  
  •   hukangha · 2016-05-23 23:34:00 +08:00 · 3053 次点击
    这是一个创建于 2885 天前的主题,其中的信息可能已经有所发展或是发生改变。
    刚找一个功能好久 ( 删除整句命令 ),最终找到一些快捷键,但是这些都不在菜单里,那么像这种快捷键一般去哪里看呢?或者说这些快捷键不属于 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
    21 条回复    2016-05-25 18:30:49 +08:00
    Citrus
        1
    Citrus  
       2016-05-24 00:20:50 +08:00 via iPhone
    你发的这些都不是 Terminal 的快捷键,而是 Bash 的快捷键。具体叫什么不记得了,等楼下科普。
    cxbig
        2
    cxbig  
       2016-05-24 00:30:10 +08:00
    这些快捷键是 bash 默认的 emacs 模式快捷键
    shell 默认是 emacs 模式,可以通过 set -o vi 切换到 vi 模式
    相对的快捷键都是基于这 2 个编辑器的操作习惯定的
    SharkIng
        3
    SharkIng  
       2016-05-24 02:18:16 +08:00 via iPhone
    长按 CMD ?
    Iblard
        4
    Iblard  
       2016-05-24 08:11:42 +08:00
    @Citrus 所有使用了 readline 库的都支持这个。
    Iblard
        5
    Iblard  
       2016-05-24 08:12:08 +08:00   ❤️ 1
    aheadlead
        6
    aheadlead  
       2016-05-24 08:20:07 +08:00 via iPhone
    readline 的文档里面有详细记载

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

    $ ping dns.v2ex.com

    想改成

    $ ping dns.baidu.com

    可以这么按

    <esc> 2
    <esc> <c-]> .
    <c-k> .baidu.com
    harry890829
        7
    harry890829  
       2016-05-24 08:31:47 +08:00
    阿西吧,我还以为什么呢,作为一个 vim 党,我还真把 shell 改为 vi 模式用过,感觉非常难用……最后还是用了 emacs 模式,也就那几个常用的,稍微记一下就好了
    Citrus
        8
    Citrus  
       2016-05-24 09:15:36 +08:00
    @Iblard 哦对就是这个! readline !
    falcon05
        9
    falcon05  
       2016-05-24 09:21:16 +08:00 via iPhone
    stty -a
    lizheming
        10
    lizheming  
       2016-05-24 09:23:53 +08:00
    推荐一个应用 CheatSheet 长按 Command 即可看当前程序的所有快捷键→_→
    aaronzjw
        11
    aaronzjw  
       2016-05-24 09:57:08 +08:00
    Dash 可以看 iterm 的快捷键
    zander
        13
    zander  
       2016-05-24 13:22:21 +08:00
    realline.
    superbear
        14
    superbear  
       2016-05-24 13:33:02 +08:00
    用 emacs 吧,它能让你更好地使用 linux 。很多快捷键和 Terminal 相同
    julyclyde
        15
    julyclyde  
       2016-05-24 16:33:34 +08:00
    @Citrus 不是 bash 的,而是 readline 的
    lightening
        16
    lightening  
       2016-05-24 16:51:23 +08:00
    这当中有一部分 Mac 全局都能用。
    znoodl
        17
    znoodl  
       2016-05-24 17:38:49 +08:00 via iPhone
    其实就是 bash 的 emacs 模式
    ghostheaven
        18
    ghostheaven  
       2016-05-24 18:01:49 +08:00 via Android
    搭车问, zsh 也用了 readline 么
    hukangha
        19
    hukangha  
    OP
       2016-05-24 23:11:42 +08:00
    @Iblard 学到新东西了
    netabare
        20
    netabare  
       2016-05-25 17:27:42 +08:00 via iPhone   ❤️ 1
    @lizheming 然而对终端机里面的 shell 没用……
    lizheming
        21
    lizheming  
       2016-05-25 18:30:49 +08:00
    @netabare 反正 Mac 下我用 Terminal 和 iTerm 都是可以的…
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1012 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 20:05 · PVG 04:05 · LAX 13:05 · JFK 16:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.