Bind this shell script to a hotkey. On hitting the hotkey, you can fuzzy search a password among those managed by the command-line tool https://www.passwordstore.org/. On selecting one of them, it is pasted at the current cursor position.
This script depends on "rofi", "dmenu", "zenity", "xsel" and "xdotool" which most linux distros offer as install packages.
To bind this shell script to a hotkey, say Meta+P
:
- Paste the below shell-script code into a file, say
~/bin/passy
, make it executable. - Install
xbindkeys
, make it autostart on logging into X, and add
"~/bin/passy"
Mod4 + p
to ~/.xbindkeysrc
.
The shell-script code:
#!/usr/bin/env bash
# Passy, fuzzy search and select and paste passwords managed by password-store. Based on:
# https://github.com/BarbUk/dotfiles/blob/master/bin/snippy
# https://github.com/peco/peco/wiki/Sample-Usage
# https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu
DIR=${HOME}/.password-store
MENU_ENGINE="rofi"
DMENU_ARGS='-dmenu -i -sort -lines 25'
MENU_ARGS=${DMENU_ARGS}
cd "${DIR}" || exit
# Use the filenames in the password-store directory as menu entries.
# Get the menu selection from the user.
FILE=$(find . -type f -name "*.gpg" \
| sed 's@\./\(.\+\?\)\.gpg@\1@' \
| ${MENU_ENGINE} ${MENU_ARGS} -p '❯ ')
# just exit if nothing was selected
[[ -z "${FILE}" ]] && exit
pass show "$FILE" \
| { IFS= read -r pass; printf %s "$pass"; } \
| xdotool type --clearmodifiers --file -
See the snippy.sh repository for the counterpart for pasting user defined snippets.