Score:0

Read keyboard input to clipboard

jp flag

I would like to be able to run read -s on the command line and send input to one of the three clipboards.

Instead of

$ read -s password 
$ echo $password | xclip -sel p

I would like to

$ read -s | xclip -sel p

How can I do this. The above example doesn't work.

vanadium avatar
cn flag
What about `read -s password && echo $password | xclip -sel p` ?
TexMor avatar
jp flag
Works like a charm! Thanks, @vanadium
vanadium avatar
cn flag
That is not fundamentally different from what you asked in your question, execpt that it is written as a one liner. This is why I did not post this as an answer, because your real problem is not clear.
TexMor avatar
jp flag
Valid point. What I was hoping was not to have a variable (password) hanging around with the password and after running the following (portion of script) I manually clear password variable (not desired) ** if [[ $1 == "-i" ]]; then ## Interactive mode read -p "file to mount: " file echo "password: " stty -echo read password && echo $password | xsc; stty echo read -p "keyfile: " keyfile sudo veracrypt --text --mount $file --password `xsv` --pim 0 --keyfiles $keyfile --protect-hidden no **
TexMor avatar
jp flag
That code snippet came out as a one-liner. Sorry about that
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.