简体   繁体   English

如何让鱼壳像 bash 一样删除单词

[英]How to make fish shell delete words like bash does

I'm giving a second try to the fish shell.我要再试一次鱼壳。 One thing that really annoys me is the "new" behaviour of Ctrl + w shortcut.真正让我烦恼的一件事是Ctrl + w快捷方式的“新”行为。

Consider following situation:考虑以下情况:

$ vim ~/.config/fish/config.fish

...having the cursor at the end of the line. ...将光标放在行尾。

When you press Ctrl + w , following happens:当您按Ctrl + w 时,会发生以下情况:

  • in bash: ~/.config/fish/config.fish is deleted在 bash 中: ~/.config/fish/config.fish被删除
  • in fish: only config.fish is deleted在fish中:只删除了config.fish

How can I make fish delete words that are separated by spaces only?如何让鱼删除仅由空格分隔的单词?

"\\cw" (in fish's notation) is bound to "backward-kill-path-component" (which bind \\cw will tell you). “\\cw”(以鱼的符号表示)绑定到“backward-kill-path-component”( bind \\cw会告诉你)。

If you wish, you can bind it to something else, including input functions like "backward-kill-word" or any fish script - bind \\cw backward-kill-word or bind \\cw "commandline -rt ''" (which will remove the entire current token) or bind \\cw backward-kill-bigword .如果你愿意,你可以将它绑定到其他东西,包括输入函数,比如“backward-kill-word”或任何鱼脚本 - bind \\cw backward-kill-wordbind \\cw "commandline -rt ''" (这将删除整个当前标记)或bind \\cw backward-kill-bigword See the bind documentation or bind --help for more information.有关更多信息,请参阅绑定文档bind --help

The difference between "word" and "bigword" here is that "word" will only go to the next non-word-character, which can be a "."这里的“word”和“bigword”的区别在于,“word”只会转到下一个非单词字符,可以是“.”。 or "/" or "-", among others, while "bigword" will truly go to the next whitespace character.或“/”或“-”等,而“bigword”将真正转到下一个空格字符。

Note that the "bigword" functions have only been introduced in fish 2.3.0.请注意,“bigword”函数仅在fish 2.3.0 中引入。

You can try these incantations in an interactive shell.您可以在交互式 shell 中尝试这些咒语。 If you decide to make it permanent, you'll need to add them to a function called fish_user_key_bindings .如果您决定将其永久化,则需要将它们添加到名为fish_user_key_bindings的函数中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM