Skip to content

Instantly share code, notes, and snippets.

@rtgnx
Created September 16, 2018 09:31
Show Gist options
  • Save rtgnx/d47d1d295f208efe0a86281a9976a169 to your computer and use it in GitHub Desktop.
Save rtgnx/d47d1d295f208efe0a86281a9976a169 to your computer and use it in GitHub Desktop.
Select password from password store with rofi. Fills clipboard with garbage after 30s
#!/bin/bash
[ ! -f "$(command -v rofi)" ] && echo "rofi not found" && exit 1
[ ! -f "$(command -v pass)" ] && echo "pass not found" && exit 1
PASWORD_STORE="$HOME/.password-store"
garbage() {
# Use only for throwing garbage into clipboard !!!!
tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 32 | head -n 1
}
list() {
find "$PASWORD_STORE" -type f | sed -e "s|$PASWORD_STORE/||g" | sed 's/.gpg//g'
}
NAME="$(list | rofi -dmenu)"
[ ! -f "$PASWORD_STORE/$NAME.gpg" ] && echo "File does not exists" && exit 1
pass "$NAME" | xclip -selection c
# Put some garbage into clipboard after 30s
sleep 30 && garbage | xclip -selection c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment