aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xaddpass22
1 files changed, 10 insertions, 12 deletions
diff --git a/addpass b/addpass
index 0b74c72..5b2ec20 100755
--- a/addpass
+++ b/addpass
@@ -2,7 +2,7 @@
source $HOME/.config/rofi-pass/config
-if [[ -n "$2" && "$1" == "--root" ]]; then
+if [[ -n "$3" && "$2" == "--root" ]]; then
root="${2}"
elif [[ -n $root ]]; then
root=$root
@@ -12,25 +12,24 @@ else
root="$HOME/.password-store"
fi
+Name="$2"
+
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\" 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\" Mandatory first argument - filename of password file"
+ echo "--root \"foobar\" Optional second argument - Absolute path to password store"
echo ""
- echo " Every field name has to start with \"-\""
- echo " Values should be quoted"
+ echo "+FIELD \"barbaz\" 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 --name \"my password file\" --root \"$HOME/passwords\" +user \"Richard\" +foo \"bar\" +autotype \"foo :tab user :tab pass\""
exit
else
- if [[ $* != *"-name "* ]]; then
- echo "Missing +name option. Try --help"
+ if [[ $* != *"--name "* ]]; then
+ echo "Missing --name option. Try --help"
exit
fi
fi
@@ -42,7 +41,6 @@ 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 "${root}"