The GNU screen utility has a neat feature for binding keys to
screen commands or macros. The
stuff command is particularly handy to expand some abbreviation to some other string as your typing.
For example if I'm in
screen and I use my meta key ([Ctrl-A] by default) followed by
:bindkey -t #@@ stuff "set -o vi; bind C-l:clear-screen C-i:complete" ... then
##@ becomes a quick way to set change settings of a
bash shell to my preferences even when I using a shared account (for example when I've used
sudo to get to the root shell on a server while trying to troubleshoot or fix it).
That's great and you can add those sorts of bindings into your
But if you want to make a macro for something more sensitive ... a password for example ... then you might want to add a key binding to your running
screen session without storing the contents in any file, anywhere.
How do you do that?
You'd think it would be easy using the
screen -X (capital X) switch which takes a command. But the obvious attempts to do that fail:
screen -X 'bindkey -t #@p stuff mysecretpasswordhere'
screen status bar with briefly light up with an error like -X: unknown command ...
Why is that error message so unhelpful?