clean up addpass script
This commit is contained in:
parent
6593af1cf1
commit
c1976347bc
22
addpass
22
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 "--name \"foobar\" Mandatory first argument - filename of password file"
|
||||
echo "--root \"foobar\" Optional second argument - Absolute path to password store"
|
||||
echo ""
|
||||
echo "+name \"foobar\" Needed field - filename of password file"
|
||||
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}"
|
||||
|
Loading…
Reference in New Issue
Block a user