aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorten Linderud <morten@linderud.pw>2018-08-08 18:04:12 +0200
committerTad Fisher <129148+tadfisher@users.noreply.github.com>2020-09-12 12:43:42 -0700
commit47acf1407c282969e6e71b09ac4d2a5d41731475 (patch)
tree823ad3337b1d67e11e1f3e3e800c00e100276a9b
parenta69c9f98ea1229ef79053fe6f336a85ddd7cf039 (diff)
downloadpass-otp-47acf1407c282969e6e71b09ac4d2a5d41731475.tar.gz
pass-otp-47acf1407c282969e6e71b09ac4d2a5d41731475.zip
Added path_prefix for insertions
Signed-off-by: Morten Linderud <morten@linderud.pw>
-rwxr-xr-xotp.bash8
1 files changed, 6 insertions, 2 deletions
diff --git a/otp.bash b/otp.bash
index d4c7756..174b37f 100755
--- a/otp.bash
+++ b/otp.bash
@@ -195,7 +195,7 @@ cmd_otp_version() {
cmd_otp_insert() {
local opts force=0 echo=0 from_secret=0
- opts="$($GETOPT -o fesi:a: -l force,echo,secret,issuer:,account: -n "$PROGRAM" -- "$@")"
+ opts="$($GETOPT -o fesi:a:p: -l force,echo,secret,issuer:,account:,path: -n "$PROGRAM" -- "$@")"
local err=$?
eval set -- "$opts"
while true; do case $1 in
@@ -204,10 +204,11 @@ cmd_otp_insert() {
-s|--secret) from_secret=1; shift;;
-i|--issuer) issuer=$2; shift; shift;;
-a|--account) account=$2; shift; shift;;
+ -p|--path) path_prefix=$2; shift; shift;;
--) shift; break ;;
esac done
- [[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND insert [--force,-f] [--echo,-e] [--secret, -s] [--issuer,-i issuer] [--account,-a account] [pass-name]"
+ [[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND insert [--force,-f] [--echo,-e] [--secret, -s] [--issuer,-i issuer] [--account,-a account] [--path,-p path] [pass-name]"
local prompt path uri
if [[ $# -eq 1 ]]; then
@@ -231,6 +232,9 @@ cmd_otp_insert() {
if [[ -z "$path" ]]; then
[[ -n "$otp_issuer" ]] && path+="$otp_issuer/"
path+="$otp_accountname"
+ if [ -n "$path_prefix" ]; then
+ path="${path_prefix%/}/$path"
+ fi
yesno "Insert into $path?"
fi