Disable PowerShell beep on backspace Win10

When pressing Backspace in PowerShell, it will emit a 'beep' sound if there is no (more) text to delete. This is quite annoying if you accidentally hold down the key too long, as the sound will keep going for a short while after you release it.

Solution :

The beep is provided by the PSReadline module, which shipped with Windows 10. You need to change the PSReadline option to disable the bell:
Set-PSReadlineOption -BellStyle None

If you want this change for all future PowerShell sessions, then you need to add this command to your PowerShell profile. For example, to set the option for "Current User, Current Host" ($Profile):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
if (!(Test-Path -Path "$Profile")) {New-Item -ItemType File -Path "$Profile" -Force}
Add-Content -Value "Set-PSReadlineOption -BellStyle None" -Path "$Profile"
The first line allows your profile run a startup script when PowerShell opens (About Execution Policies). The second line tests to see if you already have a startup script defined for "Current User, Current Host". The third line adds the bell option to your startup script.

评论

此博客中的热门博文

部署 shadowsocks-manager

如何讓 Firefox 有不同的設定檔,並讓它們能同時執行,實現帳號多開、區隔不同用途的瀏覽環境?

使用 shadowsocks Manager 搭建 SS 多人管理平台 Debian/Ubuntu