aboutsummaryrefslogtreecommitdiffstats
path: root/addpass
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2015-07-17 01:53:12 +0200
committerRasmus Steinke <rasi@xssn.at>2015-07-17 01:53:12 +0200
commit9de35776aee90fe692ae6641a40057185cdb5bd2 (patch)
tree0d456e23931052ce6c949d1662760d9e2cb8e53c /addpass
parent7120678a52ec6f809a8d3abc8356de92fbffcaf7 (diff)
downloadrofi-pass-9de35776aee90fe692ae6641a40057185cdb5bd2.tar.gz
add script to easily insert new entry
Diffstat (limited to 'addpass')
-rwxr-xr-xaddpass34
1 files changed, 34 insertions, 0 deletions
diff --git a/addpass b/addpass
new file mode 100755
index 0000000..1234ba0
--- /dev/null
+++ b/addpass
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+source $HOME/.config/rofi-pass/config
+
+if [[ -n "$2" && "$1" == "--root" ]]; then
+ root="${2}"
+else
+ :
+fi
+
+OIFS=$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}"
+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}"
+
+printEntry () {
+ echo -e "$pass\n---"
+ for ((i=1; i<${#fieldsArray[@]}; ++i)); do
+ field=$(echo "${fieldsArray[$i]}" | awk -F' ' '{print $1}')
+ option=$(echo "${fieldsArray[$i]}" | cut -d ' ' -f 2- | sed -e 's/[[:blank:]]\+$//')
+ echo "$field: $option" | grep -Ev 'name:' #${fieldsArray[$i]}";
+ done
+}
+
+printEntry | pass insert -m "${root}/${group}/${name}"