add ZPASS_COPY_ON_EDIT config

This commit is contained in:
zawz 2021-10-20 17:50:06 +02:00
parent 76a1049d86
commit dbe55ab7c0
3 changed files with 13 additions and 5 deletions

View file

@ -45,6 +45,8 @@ usage()
ZPASS_REMOTE_USER User for login
ZPASS_REMOTE_PASSWORD Password for ftps/webdav login. Not for SSH
ZPASS_PRIORITIZE_CLI Key prompt will always be done on CLI if stdin is a tty
ZPASS_COPY_ON_EDIT Set to true, edit operations will copy the affected element
> set , file , add , new
All operations can be shortened to their first char unless specified
Unknown first argument will perform the operation described in 'ZPASS_UNK_OP_CALL' on that argument

View file

@ -28,11 +28,11 @@ case $arg in
ch|cached) get_key_cached >/dev/null ;;
rmc|rm-cache) delete_cache 0 >/dev/null ;;
c|create) create_file ;;
t|tree) sanitize_paths "$@" && _tree "$@" ;;
s|set) sanitize_paths "$1" && _set "$@" ;;
f|file) sanitize_paths "$1" && fileset "$@" ;;
a|add) sanitize_paths "$@" && add "$@" ;;
n|new) sanitize_paths "$@" && new "$@" ;;
t|tree) sanitize_paths "$@" && _tree "$@" ;;
s|set) sanitize_paths "$1" && _set "$@" && cond_copy "$1" ;;
f|file) sanitize_paths "$1" && fileset "$@" && cond_copy "$1";;
a|add) sanitize_paths "$@" && add "$@" && shift $(($#-1)) && cond_copy "$1";;
n|new) sanitize_paths "$@" && new "$@" && shift $(($#-1)) && cond_copy "$1";;
g|get) sanitize_paths "$@" && get "$@" ;;
x|copy) sanitize_paths "$1" && copy "$1" ;;
l|ls|list) sanitize_paths "$@" && __NOPACK=y archive_exec ls -Ap1 -- "$@" ;;

View file

@ -99,3 +99,9 @@ move()
mv -f -- "$@"
' zpass "$@"
}
cond_copy() {
if [ "$ZPASS_COPY_ON_EDIT" = true ] ; then
copy "$1"
fi
}