bash 在不重启 xterm 的情况下重新加载 .Xresources

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21746654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 00:40:21  来源:igfitidea点击:

Reload .Xresources without restarting the xterm

bashvimescapingxtermalt

提问by Nabil Sham

To use ALT key in vim without tweaking, the escaping should be disabled in xterm. Without escaping the ALT will not work in bash for shortcuts.

要在 vim 中使用 ALT 键而不进行调整,应该在 xterm 中禁用转义。不转义 ALT 将无法在 bash 中用作快捷方式。

to work around I need to reload this option before starting vim:

要解决此问题,我需要在启动 vim 之前重新加载此选项:

XTerm*metaSendsEscape: false | xrdb -load 

Any idea how I can reload .Xresource and make changes take effect without restarting the terminal window ?
Open to other terminal to have ALT work both in vim and bash.

知道如何在不重新启动终端窗口的情况下重新加载 .Xresource 并使更改生效吗?
打开其他终端,让 ALT 在 vi​​m 和 bash 中都能工作。

采纳答案by Thomas Dickey

xterm will notreread resources just because you run xrdb. X applications only read resources when they are initializing.

xterm不会因为您运行xrdb. X 应用程序仅在初始化时读取资源。

Besides the menu entry (added in patch #122, 1999), one could use two other ways to change the metaSendsEscaperesource:

除了菜单项(在补丁 #122, 1999 中添加)之外,还可以使用其他两种方法来更改metaSendsEscape资源:

  • escape sequence, documented in XTerm Control Sequences

    CSI ? Pm h DEC Private Mode Set (DECSET). ... Ps = 1 0 3 6 -> Send ESC when Meta modifies a key. (This enables the metaSendsEscape resource).

  • editres(but very cumbersome due to the large number of resources)

  • 转义序列,记录在XTerm 控制序列中

    CSI ? Pm h DEC Private Mode Set (DECSET). ... Ps = 1 0 3 6 -> Send ESC when Meta modifies a key. (This enables the metaSendsEscape resource).

  • editres(但由于资源多而非常繁琐)

回答by doc1623

This will reload the .Xresources:

这将重新加载.Xresources

xrdb ~/.Xresources

Source: Arch wiki

资料来源:Arch wiki

回答by i336_

YAY, just checked, and XTerm has the option in its menu! I thoughtI saw it in there...

是的,刚刚检查,XTerm 在其菜单中有选项!我还以为在里面看到了...

XTerm responds to each of left-, middle- (aka scrollwheel) and right-click with individual option menus when you're holding down the Ctrl key.

当您按住 Ctrl 键时,XTerm 会响应每个左、中(又名滚轮)和右键单击的各个选项菜单。

In your case, "Meta Sends Escape" is in the ctrl+left-click menu :)

在您的情况下,“元发送转义”位于 ctrl+左键单击菜单中:)

Also, examining all three menus (if just to be aware of the options' existence) is a very good idea. I frequently use the font selector, for example.

此外,检查所有三个菜单(如果只是为了了解选项的存在)是一个很好的主意。例如,我经常使用字体选择器。

回答by sjas

Had to put xterm*metaSendsEscape: trueinto .Xdefaults, using .Xresourcesdid not want to work for me under 16.04.

只好把xterm*metaSendsEscape: true.Xdefaults,使用.Xresources不想对我来说有效16.04下方。

Followed up by a xrdb ~/.Xdefaults.

紧随其后的是一个xrdb ~/.Xdefaults