How can I make ring the bell from command line using WSL (2)?
I tried:
beep
echo -ne '\007'
echo -e "\a"
I have set bellstyle none
in /etc/inputrc.
Using Ubuntu 18.04 image.
In WSL Ubuntu or Alpine with default path setup, you can depend on .net's Console.Beep method:
powershell.exe '[console]::beep(261.6,700)'
It makes a handy alias for etc/profile
or ~/.bashrc
:
alias bloop="powershell.exe '[console]::beep(261.6,700)'"
Define a helper function to create multiple tones:
_beep () {
powershell.exe "[console]::beep($1,$2)"
}
alias bleep="_beep 1000 800" # A strong bleep (for profanity)
alias beep="_beep 2000 300" # Quick yet noticeable beep
alias blip="_beep 4000 80" # A less distracting blip
Example: Blip on success, but bleep on failure:
make && blip || bleep
set bellstyle none
if you want the bell to ring? echoing the bell character in my WSL produces the default windows "ding"