perf(completion): optimize remote to use cache
This commit is contained in:
parent
1eb7a078aa
commit
804780df8b
3 changed files with 8 additions and 1 deletions
2
Makefile
2
Makefile
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
var_exclude = ZPASS_.* XDG_.* REMOTE_.* DISPLAY CONFIGFILE TMPDIR DEBUG
|
var_exclude = _ZPASS_.* ZPASS_.* XDG_.* REMOTE_.* DISPLAY CONFIGFILE TMPDIR DEBUG
|
||||||
fct_exclude = _stop sftp_cmd ftps_cmd upload download list delete create
|
fct_exclude = _stop sftp_cmd ftps_cmd upload download list delete create
|
||||||
|
|
||||||
zpass: src/*
|
zpass: src/*
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ _zpass_completion()
|
||||||
local cur=$2
|
local cur=$2
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
|
|
||||||
|
export _ZPASS_USE_CACHE=true
|
||||||
|
|
||||||
if { [ "$COMP_CWORD" -eq "2" ] && echo "$_cw1_val1" | grep -qw -- "${COMP_WORDS[1]}" ; } ||
|
if { [ "$COMP_CWORD" -eq "2" ] && echo "$_cw1_val1" | grep -qw -- "${COMP_WORDS[1]}" ; } ||
|
||||||
{ [ "$COMP_CWORD" -gt "1" ] && echo "$_cw1_val_all" | grep -qw -- "${COMP_WORDS[1]}"; } ; then
|
{ [ "$COMP_CWORD" -gt "1" ] && echo "$_cw1_val_all" | grep -qw -- "${COMP_WORDS[1]}"; } ; then
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,11 @@ EOF
|
||||||
|
|
||||||
# $1 = protocol, $2 = remote file , $3 = local file
|
# $1 = protocol, $2 = remote file , $3 = local file
|
||||||
download() {
|
download() {
|
||||||
|
if [ "$_ZPASS_USE_CACHE" = true ] && [ -f "$(get_filecache)" ] ; then
|
||||||
|
cp "$(get_filecache)" "$3"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
scp) scp_cmd "${remote_user+${remote_user}@}$remote_host:$2" "$3" ;;
|
scp) scp_cmd "${remote_user+${remote_user}@}$remote_host:$2" "$3" ;;
|
||||||
webdav) webdav_cmd "$2" > "$3" ;;
|
webdav) webdav_cmd "$2" > "$3" ;;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue