dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.42k stars 661 forks source link

How can I disable bell sound? #954

Open hwooo opened 3 years ago

hwooo commented 3 years ago

I'm using mycli on Windows Terminal. I disabled bell sound in the terminal so there is no beep on cmd, ps, and original MySQL cli.

But there is still a beep sound inside mycli. Is there any option to disable bell inside of mycli?

j-bennet commented 3 years ago

mycli is using python-prompt-toolkit to handle console input/output. Starting from v3.0.14, python-prompt-toolkit lets you disable bell using an environment variable PROMPT_TOOLKIT_BELL=false:

https://github.com/prompt-toolkit/python-prompt-toolkit/blob/7b28b254aba3452b4ac3a797942474d14c92561f/CHANGELOG#L41

Give it a try and let us know if this helps.

hwooo commented 3 years ago

Do I have to install python-prompt-toolkit separately? or can I configure it in .myclirc file?

j-bennet commented 3 years ago

If you have mycli installed, you already have prompt-toolkit installed. Mycli would not work without it.

python -m pip freeze would show you all installed python modules and their versions.

hwooo commented 3 years ago

I can't find proper solution without rebuilding mycli :(

j-bennet commented 3 years ago

I guess I should have asked how you installed mycli in the first place. It was not pip install mycli?

hwooo commented 3 years ago

No, I intalled mycli with pip.

j-bennet commented 3 years ago

So what does pip freeze | grep prompt-toolkit tell you?

hwooo commented 3 years ago

In PowerShell, pip freeze | findstr prompt-toolkit gives me following results:

prompt-toolkit @ file:///tmp/build/80754af9/prompt-toolkit_1602688806899/work
j-bennet commented 3 years ago

I see. Not very helpful. How about this?

$ python
>>> import prompt_toolkit
>>> prompt_toolkit.__version__
'3.0.8'

If you have 3.0.14 or above, running mycli like this should work:

PROMPT_TOOLKIT_BELL=false mycli

If you have something lower, you can upgrade prompt-toolkit with:

pip install -U prompt-toolkit

alternatively, you could upgrade mycli and all related packages with:

pip install -U mycli

see if this helps.

hwooo commented 3 years ago
❯ PROMPT_TOOLKIT_BELL=false mycli
PROMPT_TOOLKIT_BELL=false : The term 'PROMPT_TOOLKIT_BELL=false' is not recognized as the name of a cmdlet, function,
script file, or operable program.

I have prompt_toolkit of version 3.0.16, but the command PROMPT_TOOLKIT_BELL=false mycli doesn't seem to work on Windows. I just turned off entire alert in Control center :(

j-bennet commented 3 years ago

You're right, Windows / PowerShell has different syntax. It would be something like this:

> $env:PROMPT_TOOLKIT_BELL = 'false'
> mycli

I'm on a Mac, so I'm flying blind here, sorry.

hwooo commented 3 years ago

It's okay. But $env:PROMPT_TOOLKIT_BELL = 'false' also doesn't work. 😂

j-bennet commented 3 years ago

I see. I should give up on trying to fix a Windows problem! @dbcli/mycli-core are any of you able to try this on Windows?