From 750c0f4f8b14630d4eecdd985bb17531527856a6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 28 Nov 2019 18:31:30 +0000 Subject: [PATCH] pash: Added PASH_CLIP to control clipboard command --- README.md | 10 ++++++++++ pash | 17 +++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1bfdf08..26acdc5 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ pash * [How do I change the password store location?](#how-do-i-change-the-password-store-location) * [How do I rename an entry?](#how-do-i-rename-an-entry) * [How can I extend `pash`?](#how-can-i-extend-pash) +* [How do I change the clipboard tool?](#how-do-i-change-the-clipboard-tool) @@ -146,3 +147,12 @@ pash() { esac } ``` + +## How do I change the clipboard tool? + +Set the environment variable `PASH_CLIP` to a command. + +```sh +# Default: 'xclip -selection clipboard'. +export PASH_DIR='xclip -selection clipboard' +``` diff --git a/pash b/pash index 8e79409..3b546f8 100755 --- a/pash +++ b/pash @@ -44,7 +44,7 @@ pw_add() { # Use 'gpg' to store the password in an encrypted file. The # 'GPG_TTY' environment variable is set to workaround cases # where 'gpg' cannot find an attached terminal. - echo "$pass" | "$gpg" "$@" -o "$name.gpg" && + printf %s "$pass" | "$gpg" "$@" -o "$name.gpg" && printf '%s\n' "Saved '$name' to the store." } @@ -67,12 +67,16 @@ pw_show() { pw_copy() { pw_show "$1" copy - if [ "$TMUX" ]; then - tmux load-buffer "$pass" + # Disable warning against words-splitting as it is safe + # and intentional. The '-f' disables globbing while the + # clipboard string is split. + # shellcheck disable=2086 + { + set -f + set +f ${PASH_CLIP:-xclip -selection clipboard} + } - elif hash xclip; then - echo "$pass" | xclip -selection clipboard - fi + printf %s "$pass" | "$@" } pw_list() { @@ -134,6 +138,7 @@ pash 1.0.0 - simple password manager. Using a key pair: export PASH_KEYID=XXXXXXXX Password length: export PASH_LENGTH=50 Store location: export PASH_DIR=~/.local/share/pash +Clipboard tool: export PASH_CLIP='' " exit 1 }