在 Windows 10 上禁用 Linux Bash 的蜂鸣声
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36724209/
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
Disable beep of Linux Bash on Windows 10
提问by Andrea Tulimiero
Having a Linux Bashon Windows 10is pretty cool, but as far as I've got to struggle with the not-so-good terminal provided from Microsoft I'm gonna get stuck with Ubuntu for everything.
Anyway, is there a way to turn offthat beepwhenever you do something on the Bash?
Since it is not possible to comment out bell-style audible
because is not there, nor is it possible to launch sc config beep start= disabled
在Windows 10上使用 Linux Bash非常酷,但就我必须与微软提供的不太好的终端作斗争而言,我将在所有方面都被 Ubuntu 卡住。
无论如何,有没有办法在你在 Bash 上做某事时关闭那个哔哔声?因为不存在所以不能
注释掉,也不能启动bell-style audible
sc config beep start= disabled
回答by Andrea Tulimiero
To disable the beep in bashyou need to uncomment (or add if not already there) the line
set bell-style none
in your/etc/inputrc
file.Note:Since it is a protected file you need to be a privileged user to edit it (i.e. launch your text editor with something like
sudo <editor> /etc/inputrc
).To disable the beep also in vimyou need to add
set visualbell
in your~/.vimrc
file.To disable the beep also in less(i.e. also in man pages and when using "git diff") you need to add
export LESS="$LESS -R -Q"
in your~/.profile
file.
要禁用哔的bash你需要取消注释(或添加如果尚未有)线
set bell-style none
在你的/etc/inputrc
文件中。注意:由于它是受保护的文件,您需要成为特权用户才能对其进行编辑(即使用类似 的内容启动您的文本编辑器
sudo <editor> /etc/inputrc
)。要在vim 中也禁用哔声,您需要添加
set visualbell
到您的~/.vimrc
文件中。要在less(即也在手册页和使用“git diff”时)禁用哔声,您需要添加
export LESS="$LESS -R -Q"
到您的~/.profile
文件中。
回答by TedMilker
Since the only noise terminals tend to make is the bell and if you want it off everywhere, the very simplest way to do it for bash on Windows:
由于唯一的噪音终端往往是钟声,如果您想在任何地方都关闭它,那么在 Windows 上为 bash 执行此操作的最简单方法是:
- Mash backspace a bunch at the prompt
- Right click sound icon and choose Open Volume Mixer
- Lower volume on Console Window Host to zero
- 在提示符下混合退格
- 右键单击声音图标并选择打开音量混合器
- 将控制台窗口主机上的音量降低到零
回答by MWin123
Uncommenting set bell-style none
in /etc/inputrc
and creating a .bash_profile
with setterm -blength 0
didn't stop vim from beeping.
取消注释set bell-style none
中/etc/inputrc
,创造一个.bash_profile
有setterm -blength 0
没有发出蜂鸣音停止VIM。
What worked for me was creating a .vimrc
file in my home directory with set visualbell
.
对我有用的是.vimrc
在我的主目录中创建一个文件set visualbell
。
Source: https://linuxconfig.org/turn-off-beep-bell-on-linux-terminal
来源:https: //linuxconfig.org/turn-off-beep-bell-on-linux-terminal
回答by Nemo
You need add following lines to bash and vim config,
您需要在 bash 和 vim 配置中添加以下行,
1) Turn off bell for bash
1) 关闭 bash 铃声
vi ~/.inputrc
set bell-style none
2) Turn off bell for vi
2)关闭vi的铃声
vi ~/.vimrc
set visualbell
set t_vb=
Setting the visual bell turns off the audio bell and clearing the visual bell length deactivates flashing.
设置可视铃会关闭音频铃,清除可视铃长度将停用闪烁。
回答by Juha Palom?ki
Replace in System Sounds the "Critical Stop" to a wav-file which is silent 1.
将 System Sounds 中的“Critical Stop”替换为无声的 wav 文件1。
Just removing the sound completely did not work for me. Apparently some default sound was used in this case.
完全消除声音对我不起作用。显然在这种情况下使用了一些默认声音。
(Credits for this.lau_ on SuperUserfor discovering this).
(在SuperUser上发现this.lau_ 的功劳)。
回答by NoZero
its not specific to bash windows 10. but if you want remove the bell terminal for zsh, just use the right option in zshrc. (for vim, answer already posted)
它不特定于 bash windows 10。但是如果你想删除 zsh 的钟形终端,只需在 zshrc 中使用正确的选项。(对于vim,答案已经发布)
unsetopt beep
http://zsh.sourceforge.net/Doc/Release/Options.html
http://zsh.sourceforge.net/Doc/Release/Options.html
i have find this option quickly, but would find it even faster if its was on this post ^^
我很快就找到了这个选项,但如果它在这篇文章中,我会更快找到它^^
hf
高频
回答by Brett Lapierre
right click on sound icon (bottom right) >>> open volume mixer >>> mute console window host
右键单击声音图标(右下角)>>> 打开音量混音器 >>> 静音控制台窗口主机
回答by GobiJerboa
I found that TedMilker's solution worked, but I would need to readjust the Volume Mixer each time I restarted. To make it permanent, I adjusted volume levels within the Windows App Volume and Device Preferences.
我发现 TedMilker 的解决方案有效,但每次重新启动时我都需要重新调整音量混合器。为了使其永久有效,我在 Windows 应用音量和设备首选项中调整了音量级别。
Taken from this post:
取自这篇文章:
Settings / System / Sound / App volume and device preferences
设置/系统/声音/应用音量和设备首选项
Set Console Window Host to Zero.
将控制台窗口主机设置为零。
(You may need to hit Tab / Backspace in the console window to trigger the bell sound before the Console Window Host slider appears.)
(在控制台窗口主机滑块出现之前,您可能需要在控制台窗口中按 Tab / Backspace 来触发铃声。)
回答by Romain Pokrzywka
To disable the beeps when ssh-ing in a remote machine, simply create the same ~/.inputrc
and ~/.vimrc
files on the remote machine to stop ssh itself from beeping.
要在远程机器上 ssh-ing 时禁用哔哔声,只需在远程机器上创建相同的~/.inputrc
和~/.vimrc
文件以阻止 ssh 本身发出哔哔声。
See the answer from @Nemo for the contents of each file.
有关每个文件的内容,请参阅 @Nemo 的答案。
回答by raisinrising
In addition to what jgr208 said, you may have a ~/.profile
file already and ~/.bash_profile
may not be present, as was the case with me.
除了 jgr208 所说的之外,您可能已经有一个~/.profile
文件,但~/.bash_profile
可能不存在,就像我的情况一样。
In this case, add setterm -blength 0
to the .profile
.
在这种情况下,添加setterm -blength 0
到.profile
.
If you create a .bash_profile
, your .profile
will be ignored and anything Windows wrote there will not work.
如果您创建一个.bash_profile
,您.profile
将被忽略,Windows 在那里写的任何内容都将不起作用。