MSysGit Bash - 如何启用 Ctrl+左/右箭头?
有没有办法在随 MSysGit 安装的 Bash 控制台中启用 Ctrl + ← / → 键盘快捷键(转到上一个/下一个单词)?
Is there a way to enable Ctrl + ← / → keyboard shortcuts (go to previous / next word) in the Bash console installed with MSysGit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
添加到我的 ~/.inputrc
对我来说就足够了。
Adding to my ~/.inputrc
Was enough for me.
这在 Windows 7 中对我有用:
将其添加到
~/.inputrc
然后重新启动控制台,它应该可以为您工作。
这使得您可以使用
CTRL+← 或 CTRL+→
或
ALT< /kbd>+← 或 ALT+→
This worked for me in Windows 7:
Add this to the
~/.inputrc
Then restart the console and it should work for you.
This makes it so you can do either use
CTRL+← or CTRL+→
Or
ALT+← or ALT+→
对于那些对为什么它不适用于 ctrl+左箭头 和 ctrl+右箭头 感到困惑的人。
这是因为 Windows 7(可能还有其他操作系统)和 msys 中的一个错误,其中 ctrl 键无法被识别(至少对于我的情况)。
要检查您是否处于相同的情况,请执行@Dennis所说的操作:
仅按 重复左箭头。
如果它们相同,欢迎来到我的世界。您现在可以使用 Autohotkey 重新映射按键或使用较新的 Windows git bash.
For those confused on why it is not working for the ctrl+Left-Arrow and ctrl+Right-Arrow.
This is because of a bug with windows 7, maybe others, and msys where the ctrl key would not be recognized (at least for my case).
To check if you are in the same situation, do what @Dennis say:
Repeat with only pressing the Left-Arrow.
If they are identical, welcome to my world. You can now use Autohotkey to remap the keys or use the newer windows git bash.
我编辑了文件 /etc/inputrc:
并注释了以下几行:
然后我编辑了文件 ~/.bashrc:
并在底部添加了以下几行
:似乎有效,而且至少到目前为止,没有副作用。
(在 Ubuntu GnomeShell Remix 12.04 AMD64 上测试)
I edited the file /etc/inputrc:
and commented out the following lines:
Then I edited the file ~/.bashrc:
and added the following lines at the bottom:
It seems to work and, at least so far, without side effects.
(tested on Ubuntu GnomeShell Remix 12.04 AMD64)
在 Bash 提示符下,按 Ctrl-v Ctrl-向左箭头 和 Ctrl-v Ctrl-右箭头 并记下输出。您应该看到类似以下内容:
^[OD
和^[OC
或类似内容。将以下行添加到您的~/.inputrc
中:您将在其中替换
\e
为转义符 (^[
) 和其余字符你得到了(OD
、OC
或类似的)。要重新读取文件并立即使更改生效,请按 Ctrl-x Ctrl-r。
At your Bash prompt, press Ctrl-v Ctrl-Left-Arrow and Ctrl-v Ctrl-Right-Arrow and make note of the output. You should see something like:
^[OD
and^[OC
or similar. Add the following lines to your~/.inputrc
:where you will substitute
\e
for escape (^[
) and the rest of the characters you got (OD
,OC
or similar).To re-read the file and make the changes active immediately, press Ctrl-x Ctrl-r.
我在 AskUbuntu 上找到了 tan 的这个答案,在这些答案都不起作用之后,它对我有用。我会在这里重新发布。
您的
~/.inputrc
和/etc/inputrc
中有什么?我认为,让这些键正常工作的最低限度是:如果您在
/etc/inputrc
中有这些键,则需要将 文件包含在~/.inputrc
中,因此检查它是否具有以下行:I found this answer by tan on AskUbuntu, which worked for me after none of these answers did. I'll repost it here.
What is in your
~/.inputrc
and/etc/inputrc
? The minimum to get those keys working is, I think:If you have these in
/etc/inputrc
, the file needs to be included from~/.inputrc
, so check that it has the following line:没有真正回答您的问题,但您可以尝试 ALT-F 和 ALT-B 代替。
Not really answering your question, but you can try ALT-F and ALT-B instead.