#!/usr/bin/env bash

. /usr/share/nvm/init-nvm.sh

if [[ $(passbolt auth check) != 'You are already logged in.' ]]
then
	passbolt auth login
fi

tmp=$(mktemp)
trap 'rm $tmp' EXIT


uuid=$(passbolt find | tail -n+2|rofi -columns 1  -width 80 -p "Password for" -dmenu "$@" | awk '{print $NF}')

[[ -n "$uuid" ]] || exit

passbolt get "$uuid" | gpg -q | xclip -i -selection clipboard
