【问题标题】:Insert first word of previous command in ZSH command line在 ZSH 命令行中插入前一个命令的第一个字
【发布时间】:2018-01-12 15:33:24
【问题描述】:

在 zsh(和 bash)中,我可以使用 ALT+. 将上一个命令的最后一个参数插入命令行。

第一个词有类似的吗?

示例:运行/bin/ls -l /tmp 后,我希望它插入/bin/ls

【问题讨论】:

    标签: zsh


    【解决方案1】:

    在 .zshrc 中找到了这个

    insert-first-word () { zle insert-last-word -- -1 1 }
    zle -N insert-first-word
    bindkey '^[_' insert-first-word
    

    然后 alt + _

    【讨论】:

    • 这也可以在我的 .zshrc 中找到;) 我只将快捷方式更改为 Alt+,因为逗号留给点键,这对我来说更有意义。我选择这个作为接受的答案,因为它比我发现的built-in solution 更方便......它鼓励我学习一些ZLE。谢谢!
    【解决方案2】:

    我找到了Alt+number+dot and Alt+comma in Zsh and Bash,它基本上回答了我的问题:

    在zsh中,你可以做到ALT+0+

    为此按三个按钮有点笨拙,但它是内置的并且可以工作。

    【讨论】:

      猜你喜欢
      • 2018-07-17
      • 2010-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多