aboutsummaryrefslogtreecommitdiffstats
path: root/addpass
blob: 1234ba0353824183887d80e7ed5bfc8d6bea26d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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}"