Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In zsh shell, when you hit Tab twice to get tab completion, your options are displayed below your prompt. But when you make a selection, the options disappear.

I have a little script that outputs passwords to stdout based on keyword search. The only problem is, after I've copied and pasted and I'm done, the passwords stay in the terminal. I would really like to implement this "temporary" output for my passwords script. Is this possible?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

On any system that uses terminfo:

printf "The password is %s " "swordfish"
read -r line
tput cuu1; tput el

Press Enter to erase the password and quit, or Ctrl+C to quit immediately. If your system uses termcap, use tput up; tput ce. This code assumes that the cursor is still on the line with the password by the time the user pressed Enter.

share|improve this answer
    
Thanks for inadvertently showing me how to use string formatting! –  Matt Alexander Aug 7 '11 at 20:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.