# 关闭当前终端响铃 setterm -blength 0 # 或者使用 setterm -bfreq 0
xset b off
# 编辑 ~/.bashrc 或 ~/.bash_profile echo "set bell-style none" >> ~/.inputrc echo "bind 'set bell-style none'" >> ~/.bashrc # 或者直接在配置文件中添加 echo "set bell-style none" >> ~/.inputrc
# 编辑全局配置文件 sudo echo "set bell-style none" >> /etc/inputrc
查看对应终端的设置选项,通常可以在"首选项"或"设置"中找到相关选项。
# 关闭当前终端响铃 stty -ixon # 或者完全禁用 stty -echoctl
在 ~/.bashrc 中添加:
~/.bashrc
alias belloff='setterm -blength 0; setterm -bfreq 0; echo "Terminal bell disabled"' alias bellon='setterm -blength 1000; setterm -bfreq 1000; echo "Terminal bell enabled"'
然后重新加载配置:
source ~/.bashrc
编辑 /etc/inputrc 或 ~/.inputrc:
/etc/inputrc
~/.inputrc
# 禁用响铃 set bell-style none # 或者设置为可见 # set bell-style visible
执行以下命令测试:
echo -e '\a' # 这会尝试触发响铃
如果设置成功,将不会听到提示音。
推荐使用方法二(修改inputrc文件)作为永久解决方案,因为它兼容性最好且不会影响其他功能。