创建不需要回车 return 且不显示警告的 fish shell prevd 键绑定
Create fish shell prevd keybinding which doesn't require carriage return and doesn't display warning
我正在尝试将 Ctrl-减号绑定到 fish 中的 prevd。期望的行为是我按下键绑定然后转到上一个目录。我试过这个:
bind \c_ 'prevd'
问题是我必须在按下键绑定后按回车键才能工作。当我到达历史末尾时,它还会显示消息 'Hit end of history…'。我想压制这个。有谁知道我怎么能做到这一点?谢谢
The problem is that I have to press enter after pressing the keybinding for it to work
你实际上没有。 prevd
立即发生,但不会重新绘制提示,因此不会显示新目录。
所以绑定也需要做commandline -f repaint
。
Also it displays the message 'Hit end of history…' when I hit the end of history.
该消息由 prevd
在 stdout 上打印(出于某种原因)。要禁止标准输出,将其重定向到 /dev/null,如 prevd >/dev/null
.
所以,总而言之:
bind \c_ 'prevd >/dev/null; commandline -f repaint'
好像很麻烦,只是为了return到上一个目录。我的建议是创建一个缩写:
abbr -a -g -- - 'cd -'
您只需输入 -
,然后输入 [enter]
。
我正在尝试将 Ctrl-减号绑定到 fish 中的 prevd。期望的行为是我按下键绑定然后转到上一个目录。我试过这个:
bind \c_ 'prevd'
问题是我必须在按下键绑定后按回车键才能工作。当我到达历史末尾时,它还会显示消息 'Hit end of history…'。我想压制这个。有谁知道我怎么能做到这一点?谢谢
The problem is that I have to press enter after pressing the keybinding for it to work
你实际上没有。 prevd
立即发生,但不会重新绘制提示,因此不会显示新目录。
所以绑定也需要做commandline -f repaint
。
Also it displays the message 'Hit end of history…' when I hit the end of history.
该消息由 prevd
在 stdout 上打印(出于某种原因)。要禁止标准输出,将其重定向到 /dev/null,如 prevd >/dev/null
.
所以,总而言之:
bind \c_ 'prevd >/dev/null; commandline -f repaint'
好像很麻烦,只是为了return到上一个目录。我的建议是创建一个缩写:
abbr -a -g -- - 'cd -'
您只需输入 -
,然后输入 [enter]
。