hukangha
V2EX  ›  macOS

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

  •  
  •   hukangha · May 23, 2016 · 4325 views
    This topic created in 3819 days ago, the information mentioned may be changed or developed.
    刚找一个功能好久 ( 删除整句命令 ),最终找到一些快捷键,但是这些都不在菜单里,那么像这种快捷键一般去哪里看呢?或者说这些快捷键不属于 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 replies  •  2016-05-25 18:30:49 +08:00
    Citrus
    Citrus
    May 24, 2016 via iPhone
    1
    你发的这些都不是 Terminal 的快捷键,而是 Bash 的快捷键。具体叫什么不记得了,等楼下科普。
    cxbig
    cxbig
    May 24, 2016
    2
    这些快捷键是 bash 默认的 emacs 模式快捷键
    shell 默认是 emacs 模式,可以通过 set -o vi 切换到 vi 模式
    相对的快捷键都是基于这 2 个编辑器的操作习惯定的
    SharkIng
    SharkIng
    May 24, 2016 via iPhone
    3
    长按 CMD ?
    Iblard
    Iblard
    May 24, 2016
    4
    @Citrus 所有使用了 readline 库的都支持这个。
    aheadlead
    aheadlead
    May 24, 2016 via iPhone
    6
    readline 的文档里面有详细记载

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

    $ ping dns.v2ex.com

    想改成

    $ ping dns.baidu.com

    可以这么按

    <esc> 2
    <esc> <c-]> .
    <c-k> .baidu.com
    harry890829
    harry890829
    May 24, 2016
    7
    阿西吧,我还以为什么呢,作为一个 vim 党,我还真把 shell 改为 vi 模式用过,感觉非常难用……最后还是用了 emacs 模式,也就那几个常用的,稍微记一下就好了
    Citrus
    Citrus
    May 24, 2016
    8
    @Iblard 哦对就是这个! readline !
    GG668v26Fd55CP5W
    GG668v26Fd55CP5W
    May 24, 2016 via iPhone
    9
    stty -a
    lizheming
    lizheming
    May 24, 2016
    10
    推荐一个应用 CheatSheet 长按 Command 即可看当前程序的所有快捷键→_→
    aaronzjw
    aaronzjw
    May 24, 2016
    11
    Dash 可以看 iterm 的快捷键
    zander
    zander
    May 24, 2016
    13
    realline.
    superbear
    superbear
    May 24, 2016
    14
    用 emacs 吧,它能让你更好地使用 linux 。很多快捷键和 Terminal 相同
    julyclyde
    julyclyde
    May 24, 2016
    15
    @Citrus 不是 bash 的,而是 readline 的
    lightening
    lightening
    May 24, 2016
    16
    这当中有一部分 Mac 全局都能用。
    znoodl
    znoodl
    May 24, 2016 via iPhone
    17
    其实就是 bash 的 emacs 模式
    ghostheaven
    ghostheaven
    May 24, 2016 via Android
    18
    搭车问, zsh 也用了 readline 么
    hukangha
    hukangha
    OP
    May 24, 2016
    19
    @Iblard 学到新东西了
    netabare
    netabare
    May 25, 2016 via iPhone❤️1
    20
    @lizheming 然而对终端机里面的 shell 没用……
    lizheming
    lizheming
    May 25, 2016
    21
    @netabare 反正 Mac 下我用 Terminal 和 iTerm 都是可以的…
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1894 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 01:49 · PVG 09:49 · LAX 17:49 · JFK 20:49
    ♥ Do have faith in what you're doing.