diff --git a/src/help.sh b/src/help.sh index d5df196..06bc8e3 100644 --- a/src/help.sh +++ b/src/help.sh @@ -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 diff --git a/src/main.sh b/src/main.sh index 118dee6..8845fb4 100755 --- a/src/main.sh +++ b/src/main.sh @@ -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 -- "$@" ;; diff --git a/src/operation.sh b/src/operation.sh index f13340f..9ffbaf3 100644 --- a/src/operation.sh +++ b/src/operation.sh @@ -99,3 +99,9 @@ move() mv -f -- "$@" ' zpass "$@" } + +cond_copy() { + if [ "$ZPASS_COPY_ON_EDIT" = true ] ; then + copy "$1" + fi +}