make --root option absolute

This commit is contained in:
Rasmus Steinke 2015-08-20 05:19:02 +02:00
parent 2e217dc1dc
commit d36e0e16dd

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -x
# rofi-pass # rofi-pass
# (c) 2015 Rasmus Steinke <rasi@xssn.at> # (c) 2015 Rasmus Steinke <rasi@xssn.at>
@ -29,19 +29,19 @@ fi
if [[ -n "$2" && "$1" == "--root" ]]; then if [[ -n "$2" && "$1" == "--root" ]]; then
root="${2}" root="${2}"
else else
: root="${root}"
fi fi
# get all password files and create an array # get all password files and create an array
list_passwords() { list_passwords() {
if [[ -n "$root" ]]; then if [[ -z "$root" ]]; then
passwords=( "${basedir}/${root}"/**/*.gpg ) passwords=( "$HOME/.password-store"/**/*.gpg )
else else
passwords=( "${basedir}"/**/*.gpg ) passwords=( "${root}"/**/*.gpg )
fi fi
for password in "${passwords[@]}"; do for password in "${passwords[@]}"; do
filename="${password#$basedir}" filename="${password#$root}"
filename="${filename%.gpg}" filename="${filename%.gpg}"
echo "$filename" echo "$filename"
done done
@ -262,11 +262,7 @@ insertPass () {
if [[ $menu == "0 Return to Main Menu" ]]; then mainMenu if [[ $menu == "0 Return to Main Menu" ]]; then mainMenu
elif [[ $menu == "" ]]; then exit elif [[ $menu == "" ]]; then exit
elif [[ $menu == "* Accept Values and Add Password Entry" ]]; then elif [[ $menu == "* Accept Values and Add Password Entry" ]]; then
if [[ -n "$root" ]]; then cd "${root}"
cd "${basedir}/${root}"
else
cd "${basedir}"
fi
group=$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2- | _rofi -dmenu -p "Choose Group > ") group=$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2- | _rofi -dmenu -p "Choose Group > ")
if [[ -n "$root" ]]; then if [[ -n "$root" ]]; then
pass insert -m -f "${root}/${group}/${name}" < <(echo -e "${pass}\nUserName: ${user}\n---\n${URL_field}: ${domain}") pass insert -m -f "${root}/${group}/${name}" < <(echo -e "${pass}\nUserName: ${user}\n---\n${URL_field}: ${domain}")