682

How to disable visual and audio bell/beep in WSL on Windows 10?

Nemo
  • 3,285
  • 1
  • 28
  • 22
Andrea Tulimiero
  • 17,693
  • 5
  • 21
  • 28
  • 19
    This Q is not about programming as defined for StackOverflow. It **may** be more appropriate on the related sites superuser.com OR unix.stackexchange.com (Unix & Linux). Consider using the flag link at the bottom of your Q and ask the moderator to move it. Please don't post the same Q on 2 different sites. Thanks and Good Luck. – shellter Apr 19 '16 at 16:32
  • 19
    Can't you `set bell-style none` in your readline init file? That's 1. the value of the `INPUTRC` environment variable, 2. `~/.inputrc` or 3. `/etc/inputrc`. – Benjamin W. Apr 19 '16 at 16:34
  • In the meanwhile @BenjaminW. I've _set bell-style none_ in /etc/inputrc but it didn't work – Andrea Tulimiero Apr 19 '16 at 17:04
  • 8
    `/etc/inputrc` is ignored if you have a `~/.inputrc`, do you have one? Or `INPUTRC` pointing elsewhere? – Benjamin W. Apr 19 '16 at 17:05
  • No I've checked there's no ~/.inputrc. As far as the INPUTRC, I've not found it – Andrea Tulimiero Apr 19 '16 at 17:14
  • `setterm -blength 0` in .bash_profile – jgr208 Apr 19 '16 at 17:20
  • Yeah @jgr208 , it did the trick ! Thx as well Benjamin for your time – Andrea Tulimiero Apr 19 '16 at 17:25
  • 6
    @shellter I think this question is fine here. Questions don't have to be _about_ programming to qualify for SO as far as I'm aware. – quant Dec 24 '18 at 05:01
  • It is still beeping in vim... Why would anyone like to have a beeping computer? This should be off by default and not on... – Soerendip Oct 18 '19 at 01:25
  • I'm a bit behind on mod powers... how do I flag this for shifting to SuperUser again? It would be really helpful there, and if you came here from an external search engine, it shouldn't matter that it's not on SO. – icedwater Jun 12 '20 at 06:11
  • Don't forget (like I just did) to source the bashrc file. God bless whoever posted that inputrc one. I have hated that #$%^ing bell for years and it kept taunting me. promises of set bell-style gave me hope only to be pulled away when I would try to git autocomplete a branch or something, leaving me crying in vain for peace. Damn yee bell!! Damn yee!!!! – Chris Wood Feb 05 '21 at 10:00
  • Note, this this intrusive turned on by its own settings is per profile, so don't place in global section, can use gui settings, select the profile, then advanced, scroll to button to unchecked audbile bell too, then click save. – run_the_race Sep 19 '21 at 09:28
  • 1
    This question is being discussed on [meta](https://meta.stackoverflow.com/questions/414994). – cigien Dec 29 '21 at 18:49
  • 3
    @shellter WSL seems to meet "software tools primarily used by programmers"? MS's description specifically indicate that it is meant for developer use `The Windows Subsystem for Linux lets developers run a GNU/Linux environment` – Gert van den Berg Jan 30 '23 at 09:34
  • @GertvandenBerg : Well who can argue with a 990 point self-accepted self-answer? As far as I'm concerned, a `bell` in a terminal is a user issue, but I don't really care. I wish they had never bothered to break up stackexchange. So much time is wasted on "is this the right 'channel' to discuss X" ... Of course, all IMHO. And you're welcome to spend your time gathering the votes to reopen the question (-;! Good luck to all. – shellter Jan 30 '23 at 17:11
  • https://www.youtube.com/watch?v=ZPvjOsPi1xI&ab_channel=DanSheffner – Alexandros Kourtis Feb 08 '23 at 17:05

11 Answers11

1016
  1. To disable the beep in bash you 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).

  2. To disable the beep and the visual bell also in vim you need to add the following to your ~/.vimrc file:

    set visualbell
    set t_vb=
    
  3. 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.

NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70
Andrea Tulimiero
  • 17,693
  • 5
  • 21
  • 28
  • 59
    For a quick one-time solution sounds can be disabled via Windows Volume Mixer https://github.com/Microsoft/BashOnWindows/issues/715#issuecomment-238010146 – Olga Apr 28 '17 at 14:01
  • 86
    FYI, I had to restart my console for this to apply, but it did work! – TJB Jul 03 '17 at 16:20
  • 4
    @TJB I think it should be enough to launch `source path-to-.bash_profile` - or the file you changed - and the configuration will be reloaded, so to save you from restarting the console. However I'm pleased it worked ! – Andrea Tulimiero Jul 04 '17 at 09:18
  • You can simply type `bash` without restarting for the setting to apply. – Joel Christophel Sep 01 '17 at 16:06
  • 2
    It would be better if you could also add to your answer that you need to **restart console** as mentioned by @TJB or as you said `source path-to-.bash_profile` but many thanks for the help anyways. – Aman Tugnawat Apr 20 '18 at 07:48
  • 3
    This doesn't work at all. – Vince May 13 '18 at 07:10
  • 6
    I prefer @Nemo's solution which puts the setting in a user-local ~/.inputrc file, and he also fixes the beeps for vim, which is just as annoying and not addressed by this solution. Finally, note that when ssh-ing into another machine, you need to have the same .inputrc and .vimrc files on the remote machine to disable the beeping from ssh. This is where Nemo's solution really shines, as you usually can't modify the system settings on remote machines. – Romain Pokrzywka Oct 10 '18 at 16:41
  • 1
    In case you need to ssh and don't have sudo on remote machine, add this line to your .bashrc would also do: `bind 'set bell-style none'`. This is actually less intrusive too. Also need to logout to make it work. – lnyng Dec 10 '18 at 06:43
  • 1
    For some reason `source` doesn't work, you need to restart the console – Mitch Jan 23 '19 at 03:23
  • I had to have the file located at ~/.inputrc and then run `bash` afterward, and it was successful – netpoetica Mar 30 '19 at 02:07
  • 2
    Note that to make the changes take affect, you must restart your bash session or reload the file ( `$ bind -f /etc/inputrc` ). – maze88 Mar 31 '19 at 15:55
  • Sourcing the .bash_profile or in my case .bashrc didn't work. Restarting works though. – Vasanth Jun 13 '19 at 22:27
  • This does nothing. – Soerendip Oct 17 '19 at 20:56
  • 2
    This removes _some_ beeps, for example if you open WSL and just hit backspace, it won't beep anymore. However, other beeps **are still audible** (e.g. the one when you hit arrow-down at the end of a vim document). I updated the answer to include how to disable it in vim. – William Nov 10 '19 at 23:18
  • A more faster way is to directly access inputrc file in the virtual path: `:\Users\\AppData\Local\Packages\CanonicalGroupLimited.UbuntunWindows_\LocalState\rootfs\etc` – mr5 Jun 23 '20 at 15:24
  • 51
    Why on earth is this not the default? Is there someone who thought, "Man, every time I tab complete what I really need to hear is BEEEP BEEEP BEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEP" – Grant Curell Jul 23 '20 at 20:51
  • 1
    It looks like this uses the windows speaker driver to deliver the beep. You can disable that from (administrator) cmd.exe: `sc stop beep` ; `sc config beep start= disabled` – user2765858 Nov 18 '20 at 18:22
  • 2
    Pleas, add the "restart terminal for changes to apply" in the bullet points since your answer works but only after the modified files are applied to your profile (hence you need to restart the terminal). I am giving you my upvote anyways – JVGD Jan 30 '21 at 11:14
  • 1
    This works great for the local WSL but doesn't work when you ssh into a server (at least not when I ssh into my Raspberry). You have to disable this on each server. But if you are using [Windows Terminal](https://github.com/microsoft/terminal), you can set `"bellStyle": "none"` in your profile defaults: https://devblogs.microsoft.com/commandline/windows-terminal-preview-1-5-release/#audible-bell-%f0%9f%94%94 – x3ro Jan 31 '21 at 09:04
  • 4
    If by any chance you are using "Windows Terminal" and you want to do it easy an fast, you can disable the terminal's bell sound directly it's config file instead of "muting" the sound in the sound mixer, you just add `"bellStyle": "none"` to your settings, and if you want to re enable just delete that line of change `none` to `audible`. No need of restarting the terminal, closing the tab or anything special, works when you save the config file. – matiaslauriti Mar 13 '21 at 22:14
  • Thanks, it drove me nuts after already a few minutes working in WSL. – Ingmar Apr 28 '22 at 11:20
  • @GrantCurell Because it is so fun to terrorize all collegues in an open office environment. It also promotes increasing your social network at work, because you need to get a new seat every day. – patrik Oct 21 '22 at 12:37
312

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:

  1. Mash backspace a bunch at the prompt
  2. Right click sound icon and choose Open Volume Mixer
  3. Lower volume on Console Window Host to zero
TedMilker
  • 3,356
  • 1
  • 15
  • 7
  • 31
    I really like the simplicity – engineercoding Jul 17 '17 at 20:20
  • 19
    Given that I ssh into a lot of servers and cannot easily manage local bash settings on all the servers, this solution was the best one for me because it was global. – Elijah W. Gagne Mar 30 '18 at 12:49
  • 43
    a windows solution for a windows-caused problem :D – PabTorre Apr 13 '18 at 15:32
  • 1
    `set bell-style none`, `setterm -blength 0` and `set visualbell` didn't work for me but this did, Thank you so much. – Ishan Jain Jun 09 '18 at 14:08
  • 1
    What am I missing? I've tried various configurations, but when I open Volume Mixer all I see is "System Sounds" -- no Console Window Host. I even tried this: https://answers.microsoft.com/en-us/windows/forum/windows_7-pictures/applications-missing-from-volume-mixer/b64bce0f-9fac-456f-a5cd-f77a59cdc6f8 – corwin.amber Jul 09 '18 at 14:20
  • 6
    Did you press backspace for a bit or some other key to make the console window make noise? Do this before opening the mixer. Applications won't appear in the mixer until Windows determines they're making noise. It will then remove them after awhile. – TedMilker Jul 09 '18 at 18:05
  • 6
    Cheese-and-rice! this is the only thing which worked for me. How f-ing annoying. Thanks @TedMilker – Ilan Oct 05 '18 at 14:04
  • 2
    We need a special up vote for the funniest working solution. :-) – Chris Oct 28 '18 at 23:02
  • I have tried every trick listed - nothing worked. I avoided your solution because as chris says it's funny. :) And as TedMilker says - f-ing annoying. Thank you!! – KateYoak Oct 11 '19 at 20:54
  • 2
    This solution didn't work for me until I decided to follow step 1. – Raptus Oct 28 '19 at 19:48
  • Sorry, but really, the solution is to turn down the volume? That's like someone asking how to make the screen darker and I tell them to turn off their monitor. What did I miss? – Dan Chase Dec 18 '19 at 04:53
  • @corwin.amber scroll to the right, esp if you use firefox – Erik Aronesty Jan 09 '20 at 17:35
  • 1
    @DanChase This works for everything in a terminal -with one change-, not just shells. If you use vim(I do) then you need to edit at least two files which is annoying. Also, more files to edit if you remote into other sites through the terminal. This kills the Terminal's bell completely in one easy place. – TedMilker Jan 10 '20 at 16:29
  • glad this simple step really worked to get rid of those annoying sound in terminal.... – vijay v Feb 16 '21 at 05:18
  • This solution also work for setting very low volume which is also fine for me. Thanks! – Luky May 18 '21 at 13:52
  • 1
    does anybody know how this solution (muting the terminal in the Volume Mixer) can be configured to be boot resistant? – David May 31 '21 at 10:42
  • One edge case still exists: When the sound comes out of a bluetooth speaker / headphones that is connected with two devices simulatiounsly, the device running the terminal is still priviledged. Therefore, windows seems to send a sound with 0% volume information to the device and the playpack of the second device stops. – mhellmeier Jun 22 '21 at 08:57
  • This is a good solution but I found that it did not persist. After some time, the mute disappeared, it's like new instances showed up which required muting again. Also, this needs to be repeated for every new terminal Window. – Nagev Jan 11 '22 at 14:43
  • This should be the accepted solution IMAO – Skallwar Apr 22 '22 at 12:29
125

You need add following lines to bash and vim config,

1) Turn off bell for bash

vi ~/.inputrc
set bell-style none

2) Turn off bell for 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.

Nemo
  • 3,285
  • 1
  • 28
  • 22
  • 11
    Thanks, this solution is my favorite as it addresses both sources of beeping, the terminal itself and vim, plus avoids the flashing from the visual bell. I also like that you're creating user profiles instead of editing the system config files in /etc – Romain Pokrzywka Oct 10 '18 at 16:36
  • Note that this also works nicely to disable beeping from ssh when accessing a remote machine, just create the same files in your home folder on the remote machine and no more beeps. – Romain Pokrzywka Oct 10 '18 at 16:49
  • Im using git git version 2.31.0. Windows ten. Windows terminal. Setting my inputrc file to "set bell-style none" worked for me. – Joshua Wolfe Mar 23 '21 at 00:15
124

Uncommenting set bell-style none in /etc/inputrc and creating a .bash_profile with setterm -blength 0 didn't stop vim from beeping.

What worked for me was creating a .vimrc file in my home directory with set visualbell.

Source: https://linuxconfig.org/turn-off-beep-bell-on-linux-terminal

MWin123
  • 1,475
  • 2
  • 12
  • 18
  • 30
    Wow, why what when were did someone think beeping was a good default? Thanks! Your answer is needed to turn off the bell sound in vi. – Andrew T Finnell Sep 27 '16 at 14:49
  • Does work for local, but no good for ssh to remote servers. – Matt Jan 30 '17 at 12:59
  • @Matt - for SSH session you need to tweak the setting in the SSH client you're using. For example, if you're using PuTTY then tweak its settings. – asterx Feb 11 '17 at 22:37
  • 1
    you need both a ~/.inputrc and a ~/.vimrc to remove the beeps both from bash and from vim, see @Nemo's solution. Also note that you need these two files on remote machines you're ssh-ing into if you want to avoid the beeping from ssh. – Romain Pokrzywka Oct 10 '18 at 16:43
39

Replace in System Sounds the "Critical Stop" to a wav-file which is silent 1.

Just removing the sound completely did not work for me. Apparently some default sound was used in this case.

System sounds configuration

(Credits for this.lau_ on SuperUser for discovering this).

Juha Palomäki
  • 26,385
  • 2
  • 38
  • 43
  • 3
    If you have a Linux box it's easy to make a 1 second sound of silence. Install sox. Then $ rec silence.wav trim 0 1 – LeviX Jan 22 '19 at 17:16
  • 3
    This helped me. When I set 'Critical Stop' to None, it was reset to 'Default Beep', I had to set that too to None. These sounds are annoying especially when we are on headphones. Windows should learn. – Venki Feb 01 '20 at 05:28
36

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)

unsetopt beep

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

19

In Windows Terminal Settings, select the profile, then click 'advanced' > 'bell notification'

and turn it off:

enter image description here

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
Phoenix Zou
  • 219
  • 2
  • 2
  • Editor here. I've removed your original answer (re: lowering the volume) and left your updated answer which is actually very good. Have an upvote! – mikemaccana Feb 08 '22 at 09:29
  • 2
    This is the best answer if you're using Windows Terminal. – ZYinMD May 19 '22 at 00:17
  • This answer is the only one that works on both `zsh` and `bash` regardless of using `ssh` or not. I recommend this one as this is not a hack. This is a built-in feature if you are using Windows Terminal. – Amir Pourmand Oct 10 '22 at 09:27
13

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.

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.)

GobiJerboa
  • 175
  • 2
  • 5
4

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.

In this case, add setterm -blength 0 to the .profile.

If you create a .bash_profile, your .profile will be ignored and anything Windows wrote there will not work.

raisinrising
  • 262
  • 1
  • 5
  • 14
2

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.

See the answer from @Nemo for the contents of each file.

Romain Pokrzywka
  • 200
  • 1
  • 12
-2

Find the location of the .bash_profile file and enter the following into the file:

setterm -blength 0

Which will set the amount of time the beep happens to 0 and thus no beep.

jgr208
  • 2,896
  • 9
  • 36
  • 64
  • 11
    This didn't work for me - the other answer about the inputrc file did – reach4thelasers Aug 03 '16 at 10:52
  • @reach4thelasers well which beep did you want to disable? as you can see below for vim and the like my answer does work. – jgr208 Aug 03 '16 at 15:33
  • It was the beep that happens when you push the delete button and go too far - so try to delete nothing... so annoying!!! – reach4thelasers Aug 05 '16 at 21:44
  • @reach4thelasers haha i know what you mean, imagine that sound during my computer lab in college with 30 students! – jgr208 Aug 08 '16 at 13:34
  • Putting the expression in the answer in `~/.bashrc` and restarting the console worked for me. NOTE: I use ConEmu64 instead of cmd. – dimitarvp Aug 20 '16 at 11:30
  • 1
    for me, only the solution To disable beep of the bash you need to uncomment/add set bell-style none in your /etc/inputrc file worked for me. – benjguin Aug 29 '16 at 09:09