From d36e0e16dd7b8811ec721bd8ebc0c2fc02710208 Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Thu, 20 Aug 2015 05:19:02 +0200 Subject: [PATCH] make --root option absolute --- rofi-pass | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/rofi-pass b/rofi-pass index c9d0d2a..25c636d 100755 --- a/rofi-pass +++ b/rofi-pass @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x # rofi-pass # (c) 2015 Rasmus Steinke @@ -29,19 +29,19 @@ fi if [[ -n "$2" && "$1" == "--root" ]]; then root="${2}" else - : + root="${root}" fi # get all password files and create an array list_passwords() { - if [[ -n "$root" ]]; then - passwords=( "${basedir}/${root}"/**/*.gpg ) + if [[ -z "$root" ]]; then + passwords=( "$HOME/.password-store"/**/*.gpg ) else - passwords=( "${basedir}"/**/*.gpg ) + passwords=( "${root}"/**/*.gpg ) fi for password in "${passwords[@]}"; do - filename="${password#$basedir}" + filename="${password#$root}" filename="${filename%.gpg}" echo "$filename" done @@ -262,11 +262,7 @@ insertPass () { if [[ $menu == "0 Return to Main Menu" ]]; then mainMenu elif [[ $menu == "" ]]; then exit elif [[ $menu == "* Accept Values and Add Password Entry" ]]; then - if [[ -n "$root" ]]; then - cd "${basedir}/${root}" - else - cd "${basedir}" - fi + cd "${root}" 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 pass insert -m -f "${root}/${group}/${name}" < <(echo -e "${pass}\nUserName: ${user}\n---\n${URL_field}: ${domain}")