【问题标题】:How to bind Ctrl-Enter in fish?如何在fish中绑定Ctrl-Enter?
【发布时间】:2016-05-09 11:08:46
【问题描述】:

为了configure a user binding(版本2.2.0),它必须在fish_user_key_bindings函数中:

function fish_user_key_bindings
    bind \n 'commandline -f accept-autosuggestion execute'
end

这很好用。

我想将此绑定扩展为 Ctrl+Enter,使用 appropriate modifier:

function fish_user_key_bindings
    bind \c\n 'commandline -f accept-autosuggestion execute'
end

这不起作用:Enter 使用当前(直到光标)建议(这是默认值)但是 Ctrl+Enter 也是(好像没有考虑带有修饰符的操作)

【问题讨论】:

  • 并非所有终端都能区分 enter 和 ctrl-enter。您使用的是哪个终端应用程序?
  • @ridiculous_fish:我在 putty/kitty 和 mobaxterm 上都试过这个

标签: fish


【解决方案1】:

我认为您想要以下内容:

bind \cf accept-autosuggestion execute

如果您安装了 vi 模式,则如下

bind -M insert \cf accept-autosuggestion execute

【讨论】:

    【解决方案2】:

    绑定\c\n 没有任何意义,因为\n 已经是一个控制字符。再次将控制修饰符应用于控制角色没有任何效果。由于\n 只是\cJ 的别名,因此您尝试做的就是绑定到\c\cJ。绑定 [Ctrl][Enter] 的唯一方法是将终端配置为发送该组合键的唯一序列。

    P.S.,如果您获取当前的 git head 源,您可以 make fish_key_reader 构建一个方便的程序,该程序将向您显示有关不同键发送的大量信息(尽管您需要等待几分钟我输入这个是因为我需要合并https://github.com/fish-shell/fish-shell/pull/3012)。

    P.P.S.,从 fish 2.3.0(目前处于 beta 测试阶段)开始,tty 驱动程序不再自动将输入键发送的\r(又名\cM)转换为\n(又名\cJ)。

    【讨论】:

      猜你喜欢
      • 2017-09-11
      • 2016-12-19
      • 1970-01-01
      • 2019-04-05
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多