How to configure bash/zsh to show a small key icon when the prompt asks for a password like Mac terminal?

enter image description here

Is this even possible?

  • Any particular reason you want this? Any graphic shown in a terminal application would be specific to that app(of custom font glyph). What happens if you ssh from another non-Mac machine?
    – rob
    Commented May 11, 2018 at 10:29
  • 1
    I just find it a nice touch, that's all, no other reason. I don't know what happens as I don't own a Mac.
    – rfgamaral
    Commented May 11, 2018 at 10:47
  • 2
    I'd guess the terminal knows it has echo disabled (eg: stty -echo) and puts this icon then. It looks to me it's not a shell feature, it's a terminal-emulator feature.
    – A.B
    Commented May 12, 2018 at 20:30

2 Answers 2


Your shell cannot help you because it isn't even active at this point. It's just sitting in the background waiting for the command to terminate. The shell runs the sudo command, after that sudo interacts with the terminal. (Suggested background reading: What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?)

It may be possible for your terminal to do what Mac terminal does. Certainly Mac terminal has this feature. I'm not aware of other terminals emulators with this feature, you may want to make a feature request to the developer of your favorite terminal emulator.


What you will notice in this case is that typing characters is being accepted by the read prompt, just the shell is not echoing them back to you and so it appears that it is not accepting input.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .