aboutsummaryrefslogtreecommitdiffstats
path: root/addpass
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2015-08-21 18:43:57 +0200
committerRasmus Steinke <rasi@xssn.at>2015-08-21 18:43:57 +0200
commit6593af1cf1202ecdfe8c1b2a08e0aa9a7b2f129f (patch)
tree879974479b63c2d3b5e4c9d3ecede847242b799e /addpass
parent59f6a80e368430547efc281bac6877470d885a00 (diff)
downloadrofi-pass-6593af1cf1202ecdfe8c1b2a08e0aa9a7b2f129f.tar.gz
use PASSWORD_STORE_DIR as fallback; use + for fieldnames
Diffstat (limited to 'addpass')
-rwxr-xr-xaddpass20
1 files changed, 12 insertions, 8 deletions
diff --git a/addpass b/addpass
index 0f22277..0b74c72 100755
--- a/addpass
+++ b/addpass
@@ -4,29 +4,33 @@ source $HOME/.config/rofi-pass/config
if [[ -n "$2" && "$1" == "--root" ]]; then
root="${2}"
+elif [[ -n $root ]]; then
+ root=$root
+elif [[ -n $PASSWORD_STORE_DIR ]]; then
+ root=$PASSWORD_STORE_DIR
else
- :
+ root="$HOME/.password-store"
fi
if [[ $1 == "--help" || $1 == "=h" ]]; then
echo "add pass files for rofi-pass"
echo "(C) 2015 Rasmus Steinke <rasi at xssn dot at>"
echo ""
- echo "--root \"foobar\" Choose the database to use"
+ echo "--root \"foobar\" Absolute path to password store"
echo " Needs to be first option."
echo " Leave empty to use top level)"
echo ""
- echo "-name \"foobar\" Needed field - filename of password file"
+ echo "+name \"foobar\" Needed field - filename of password file"
echo ""
echo " Every field name has to start with \"-\""
echo " Values should be quoted"
echo ""
echo "Example:"
- echo "adduser --root private -user \"Richard\" -foo \"bar\" -autotype \"foo :tab user :tab pass\""
+ echo "adduser --root private +user \"Richard\" +foo \"bar\" +autotype \"foo :tab user :tab pass\""
exit
else
if [[ $* != *"-name "* ]]; then
- echo "Missing -name option. Try --help"
+ echo "Missing +name option. Try --help"
exit
fi
fi
@@ -34,14 +38,14 @@ fi
echo "Using database \"$root\""
OIFS=$IFS;
-IFS="-";
+IFS="+";
fields="$@";
fieldsArray=($fields);
Name=$(printf '%s\n' "${fieldsArray[@]}" | grep "name " | cut -d ' ' -f 2- | sed -e 's/[[:blank:]]\+$//')
read -p "Enter password for entry \"${Name}\" > " -s pass
-cd "${basedir}/${root}"
+cd "${root}"
group=$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2- | rofi -dmenu -p "Choose Group > ")
echo -e "\n\nStoring file ${Name} in group ${group}"
@@ -55,5 +59,5 @@ printEntry () {
done
}
-printEntry | pass insert -m "${root}/${group}/${Name}"
+printEntry | pass insert -m "${group}/${Name}"