You can see what problem I'm having just by doing sleep 10
and typing.
How would I go about stopping that typing from showing?
To turn off keyboard echo, you can use stty -echo
. To turn it back on you can do stty echo
. To be safe, you would save the stty state and restore it at the end; however if you're reading a password, bash has a built-in -s
option to read.
In summary:
stty -echo
# keyboard input is not echoed
stty echo
# keyboard input is echoed
More complete:
state=$(stty -g)
stty -echo
# keyboard is not echoed
stty "$state"
# state is restored.
Better, if you're just asking for a password, and using bash:
read -s password
# password is now in the variable $password; no stty shenanigans
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With