add support for tmux clipboard

This commit is contained in:
Dylan Araps 2019-02-24 23:25:11 +02:00
parent ed0cc25d27
commit 82a4fb1bad
1 changed files with 12 additions and 2 deletions

14
pash
View File

@ -92,6 +92,16 @@ die() {
exit 1
}
copy() {
[[ $TMUX ]] && {
tmux load-buffer "$password"
return
}
hash xclip 2>/dev/null &&
xclip -selection clipboard &>/dev/null <<< "$password"
}
usage() { printf '%s' "\
pash - simple password manager.
usage: pash [add|del|show|list] [name] [-n,-q,-c] [-l length]
@ -152,8 +162,8 @@ main() {
*) usage ;;
esac
[[ $clipboard && $password ]] && hash xclip 2>/dev/null &&
xclip -selection clipboard &>/dev/null <<< "$password"
[[ $clipboard && $password ]] &&
copy
[[ -z $quiet && $password ]] &&
printf '%s\n' "$password"