3

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?

rfgamaral
  • 455
  • 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 May 11 '18 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 May 11 '18 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 May 12 '18 at 20:30

2 Answers2

3

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.

0

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.

djangofan
  • 4,147