xmodmap: 无法打开显示 ''

Der*_*unk 10 ssh xmodmap ubuntu

我的 .bashrc 中有以下行

xmodmap -e "keycode 116 = slash"
Run Code Online (Sandbox Code Playgroud)

当我通过 SSH 连接到那台机器时,我得到

xmodmap:  unable to open display ''
Run Code Online (Sandbox Code Playgroud)

不用说,我想要它离开那里。谁能告诉我如何清除此错误?

OpenSSH_4.7p1 Debian-8ubuntu1.2,OpenSSL 0.9.8g 2007 年 10 月 19 日

感谢您的帮助。

inn*_*naM 11

如果有可用的显示,您可以更改.bashrc为仅运行xmodmap

if [ -n "${DISPLAY+x}" ]; then
    xmodmap -e "keycode 116 = slash"
fi
Run Code Online (Sandbox Code Playgroud)