修复在 Terminator 终端模拟器中运行 Zsh 时 .zshrc 中的关键设置(Home/End/Insert/Delete)

发布于 2024-12-23 07:05:31 字数 526 浏览 2 评论 0原文

我运行的是 Ubuntu 11.04。我安装了 Terminator Terminal Emulator 0.95 和 Zsh 版本 4.3.15。
我的 Zsh 内的密钥存在(众所周知的)问题。至少这些:

  • Home/End,没有任何反应
  • 插入/删除/PageUp/PageDown:键入“~”

我已经尝试了 .zshrc 的一些配置,这应该可以解决问题,但到目前为止还没有真正有效的方法。也许这与终结者和Zsh的结合有关。我在此页面上获取了 2 个配置: https://bbs.archlinux.org/viewtopic.php?pid=428669

oneone 是否有类似的配置(尤其是 Terminator 和 Zsh)并弄清楚需要在 .zshrc 中插入什么来修复关键设置?

I'm running Ubuntu 11.04. I installed the Terminator Terminal Emulator 0.95, and Zsh, version 4.3.15.
I have (commonly known) problems with my keys inside the Zsh. At least these:

  • Home/End, nothing happens
  • Insert/Delete/PageUp/PageDown: a "~" is typed

I already tried some configurations for .zshrc which should solve the problem, but no approach really worked so far. Maybe this is related to the combination of Terminator and Zsh. I took the 2 configs on this page: https://bbs.archlinux.org/viewtopic.php?pid=428669.

Does oneone have a similar configuration (especially Terminator and Zsh) and figured out what needs to be inserted into the .zshrc to fix the key settings?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

上课铃就是安魂曲 2024-12-30 07:05:31

要了解某个键的代码,请执行 cat,按 Enter 键,按该键,然后按 Ctrl+C。

对我来说,Home发送^[[HEnd^[[F,所以我可以把我的.zshrc 在我的主目录中

bindkey  "^[[H"   beginning-of-line
bindkey  "^[[F"   end-of-line
bindkey  "^[[3~"  delete-char

这些代码可能会随着您使用的终端模拟器而改变。

自动加载 zkbd ; zkbd 将创建一个包含要使用的键码数组的文件,例如 bindkey "${key[Home]}" begin-of-line,并且您可以根据情况获取不同的文件终端。

To know the code of a key, execute cat, press enter, press the key, then Ctrl+C.

For me, Home sends ^[[H and End ^[[F, so i can put i my .zshrc in my home dir

bindkey  "^[[H"   beginning-of-line
bindkey  "^[[F"   end-of-line
bindkey  "^[[3~"  delete-char

These codes could change with the terminal emulator you use.

autoload zkbd ; zkbd will create a file with an array of keycodes to use, like bindkey "${key[Home]}" beginning-of-line, and you can source a different file depending on the terminal.

时光倒影 2024-12-30 07:05:31

感谢@lolesque,但该解决方案对我不起作用。使用 zkbd 检查我的按键绑定后,我得出了以下解决方案。顺便说一句,我的 $TERMxterm

bindkey  "^[[1~"   beginning-of-line
bindkey  "^[[4~"   end-of-line

希望有帮助。

Thanks to @lolesque, but the solution doesn't work with me. After using zkbd to check my key binding, I came out the below solution. BTW, my $TERM is xterm.

bindkey  "^[[1~"   beginning-of-line
bindkey  "^[[4~"   end-of-line

Hope it helps.

我是男神闪亮亮 2024-12-30 07:05:31

对于 WSL2(Windows 10)上的我来说,这就是

bindkey "^[OH" beginning-of-line
bindkey "^[OF" end-of-line

cat 技巧对我不起作用,因为它打印了 ^[[H ,如接受的答案所示,但我能够通过在运行 zsh 的新窗口终端中键入 Ctrl+v Home 找出 ^[OH 序列。

For me on WSL2 (Windows 10) this was it

bindkey "^[OH" beginning-of-line
bindkey "^[OF" end-of-line

The cat trick did not work for me as it printed ^[[H as in the accepted answer but I was able to find out the ^[OH sequence by typing Ctrl+v Home in the new Window Terminal running zsh.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文