Pass is the standard UNIX password manager which I have been using for a while now. Recently, I decided to uninstall my X display server and to live entirely in the TTY. An annoying result was that I could no longer follow my previous password routine which used passmenu, a dmenu-powered pass interface. I called it with a shortcut specified in my window manager and I only had to enter the name of the password file I was looking for. Once I hit enter, I provided my master password for GnuPG and then the password I was looking for was copied to my X clipboard for 45 seconds.
I multiplex my TTY with tmux which has its own clipboard. So every time I wanted to copy a password I typed this:
| tmux loadb -
GnuPG has its own TUI with which I can provide my secret key. So once I added that, my password is piped to my tmux clipboard. However I wanted to save some typing work and I wanted my beloved dmenu functionality back where while you type you are shown the options which still match your query. So I needed something like dmenu but with a TUI. Pmenu is exactly that. It can take a list of options from standard input and then outputs the one you select from it.
Here is what I came up with:
account=$(find $HOME/.password-store/ -type f -printf '%P\n' \ | sed "s/\.gpg-id//" \ | sed "s/\.gpg//" \ | pmenu); pass show $account | tmux loadb -
I first use find to list all files in .password-store. Then I remove the .gpg-id file and gpg file extensions with sed. I pipe the final list into pmenu. The output of pmenu is assigned to the account variable which I call in the final pass comand.
The biggest problem in my current solution is that the password lingers in the tmux clipboard for as long as the tmux session is running. The X clipboard used by passmenu only holds it for 45 seconds. I have not found a way to assign such a timer to the tmux clipboard. This is of course a security concern. My current workaround is to assign a shortcut for overwriting the clipboard with an empty string in the tmux.conf. I have to execute this shortcut manually however.
bind -r e run "echo '' | tmux load