aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnirudh Oppiliappan <x@icyphox.sh>2021-01-14 17:49:01 +0530
committerAnirudh Oppiliappan <x@icyphox.sh>2021-01-14 17:49:01 +0530
commit56ad0e841f177e2587b2fc3b45a35ebc6c9ee0ac (patch)
treeba92405d75a5597d876a236dfe3fa0c6d9f16552
parent46827babf93eb23b32505faa4b01fb59cf97b811 (diff)
downloadpw-56ad0e841f177e2587b2fc3b45a35ebc6c9ee0ac.tar.gz
Fix pw on fisherpriceOS
-rwxr-xr-xpw17
1 files changed, 14 insertions, 3 deletions
diff --git a/pw b/pw
index b5c8bf2..e8adefa 100755
--- a/pw
+++ b/pw
@@ -1,6 +1,13 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2# pw - a mnml password manager 2# pw - a mnml password manager
3 3
4command -v gpg >/dev/null 2>&1 && gpg=gpg
5command -v gpg2 >/dev/null 2>&1 && gpg=gpg2
6
7# check if xclip or pbcopy exist
8# command -v xclip >/dev/null 2>&1 && copy="xclip -rmlastnl -selection clipboard"
9# command -v pbcopy >/dev/null 2>&1 && copy="pbcopy | tr -d '\n'"
10
4# export PW_DIR to your own path 11# export PW_DIR to your own path
5[[ -z "$PW_DIR" ]] && PW_DIR="$HOME/.pw" 12[[ -z "$PW_DIR" ]] && PW_DIR="$HOME/.pw"
6 13
@@ -27,7 +34,7 @@ add() {
27 printf "pw: generated password for %s\n" "$1" 34 printf "pw: generated password for %s\n" "$1"
28 fi 35 fi
29 if [[ ! -f "$PW_DIR/$1.gpg" ]]; then 36 if [[ ! -f "$PW_DIR/$1.gpg" ]]; then
30 printf "%s" "$pass" | gpg2 -er "$PW_KEY" -o "$PW_DIR/$1.gpg" 37 printf "%s" "$pass" | "$gpg "-er "$PW_KEY" -o "$PW_DIR/$1.gpg"
31 printf "pw: %s/%s.gpg created\n" "$PW_DIR" "$1" 38 printf "pw: %s/%s.gpg created\n" "$PW_DIR" "$1"
32 else 39 else
33 die "the file %s/%s.gpg exists" "$PW_DIR" "$1" 40 die "the file %s/%s.gpg exists" "$PW_DIR" "$1"
@@ -52,14 +59,18 @@ del() {
52 59
53show() { 60show() {
54 checkf "$PW_DIR/$1.gpg" 61 checkf "$PW_DIR/$1.gpg"
55 gpg2 --decrypt --quiet --use-agent "$PW_DIR/$1.gpg" 62 "$gpg" --decrypt --quiet --use-agent "$PW_DIR/$1.gpg"
56} 63}
57 64
58# TODO: rework having to checkf twice 65# TODO: rework having to checkf twice
59 66
60copy() { 67copy() {
61 checkf "$PW_DIR/$1.gpg" 68 checkf "$PW_DIR/$1.gpg"
62 show "$1" | head -1 | xclip -rmlastnl -selection clipboard 69 if [[ "$OSTYPE" =~ darwin* ]]; then
70 show "$1" | head -1 | pbcopy | tr -d '\n'
71 else
72 show "$1" | head -1 | xclip -rmlastnl -selection clipboard
73 fi
63 printf "pw: copied %s to clipboard\n" "$1" 74 printf "pw: copied %s to clipboard\n" "$1"
64} 75}
65 76