如何阻止 Windows 中的 Linux 终端发出错误声音?

Pro*_*o Q 13 audio terminal windows-subsystem-for-linux

如果我在 Windows 中的一个空 Linux 终端中(使用适用于 Linux 的 Windows 子系统),并且按下退格键,我会听到这种烦人的类似错误的声音。我的 Windows 计算机曾经这样做过,但后来我将其关闭。怎么关闭这个声音?

AFH*_*AFH 19

如果您想在bash不影响其他 Windows 程序的情况下停止生成错误声音,请键入以下内容:

bind 'set bell-style none'
Run Code Online (Sandbox Code Playgroud)

如果您想要永久更改,请将其添加到~/.bashrc.


小智 5

这里使用 WLS(Ubuntu for Windows)我必须在以下位置进行编辑:

/etc/inputrc
Run Code Online (Sandbox Code Playgroud)

只需运行它并重新启动终端即可

echo 'set bell-style none' >> /etc/inputrc
Run Code Online (Sandbox Code Playgroud)

  • @viniciusgati,这可能是由于命令中的重定向造成的。您可以使用“sudo vi /etc/inputrc”(或使用您喜欢的其他文本编辑器来编辑文件)。或者检查[这个问题](https://unix.stackexchange.com/questions/106663/how-to-run-a-command-that-involves-redirecting-or-piping-with-sudo)了解有关问题和其他解决方案。 (3认同)
  • “#bell-style none”和“#bell-stylevisible”都已存在于 /etc/inputrc 中。只需删除行开头的 # 来取消注释您要使用的注释即可。额外学分:查看其他可用的 libreadline 选项。 (2认同)