about summary refs log tree commit diff
path: root/Functions/Zftp
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/Zftp')
-rw-r--r--Functions/Zftp/zfanon1
-rw-r--r--Functions/Zftp/zfcd1
-rw-r--r--Functions/Zftp/zfcget1
-rw-r--r--Functions/Zftp/zfclose1
-rw-r--r--Functions/Zftp/zfcput1
-rw-r--r--Functions/Zftp/zfdir1
-rw-r--r--Functions/Zftp/zfgcp1
-rw-r--r--Functions/Zftp/zfget1
-rw-r--r--Functions/Zftp/zfgoto1
-rw-r--r--Functions/Zftp/zfhere1
-rw-r--r--Functions/Zftp/zfinit19
-rw-r--r--Functions/Zftp/zfls1
-rw-r--r--Functions/Zftp/zfmark1
-rw-r--r--Functions/Zftp/zfopen1
-rw-r--r--Functions/Zftp/zfparams1
-rw-r--r--Functions/Zftp/zfpcp1
-rw-r--r--Functions/Zftp/zfput59
-rw-r--r--Functions/Zftp/zfsession1
-rw-r--r--Functions/Zftp/zfstat1
-rw-r--r--Functions/Zftp/zftp_chpwd5
-rw-r--r--Functions/Zftp/zftp_progress15
-rw-r--r--Functions/Zftp/zftransfer7
-rw-r--r--Functions/Zftp/zftype1
-rw-r--r--Functions/Zftp/zfuget1
-rw-r--r--Functions/Zftp/zfuput1
25 files changed, 102 insertions, 23 deletions
diff --git a/Functions/Zftp/zfanon b/Functions/Zftp/zfanon
index f5754dda6..85a6e1aef 100644
--- a/Functions/Zftp/zfanon
+++ b/Functions/Zftp/zfanon
@@ -2,6 +2,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfanon:
 local opt opt_1 dir
 
 while getopts :1 opt; do
diff --git a/Functions/Zftp/zfcd b/Functions/Zftp/zfcd
index 2ecc8b0f6..57760980c 100644
--- a/Functions/Zftp/zfcd
+++ b/Functions/Zftp/zfcd
@@ -20,6 +20,7 @@
 #     work just as long as the directory structures under the home match.
 
 emulate -L zsh
+[[ $curcontext = :zf*: ]] || local curcontext=:zfcd:
 
 if [[ $1 = /* ]]; then
   zfautocheck -dn || return 1
diff --git a/Functions/Zftp/zfcget b/Functions/Zftp/zfcget
index f95f37704..cdc360102 100644
--- a/Functions/Zftp/zfcget
+++ b/Functions/Zftp/zfcget
@@ -12,6 +12,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfcget:
 local loc rem stat=0 opt opt_G opt_t remlist locst remst
 local tmpfile=${TMPPREFIX}zfcget$$ rstat tsize
 
diff --git a/Functions/Zftp/zfclose b/Functions/Zftp/zfclose
index fb49efd51..92f0042b6 100644
--- a/Functions/Zftp/zfclose
+++ b/Functions/Zftp/zfclose
@@ -1,3 +1,4 @@
 # function zfclose {
+[[ $curcontext = :zf*: ]] || local curcontext=:zfclose:
 zftp close
 # }
diff --git a/Functions/Zftp/zfcput b/Functions/Zftp/zfcput
index fad5c3f86..87dde8518 100644
--- a/Functions/Zftp/zfcput
+++ b/Functions/Zftp/zfcput
@@ -12,6 +12,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfcput:
 local loc rem stat=0 locst remst offs tailtype
 local tmpfile=${TMPPREFIX}zfcget$$ rstat
 
diff --git a/Functions/Zftp/zfdir b/Functions/Zftp/zfdir
index deb5b9762..b8930b176 100644
--- a/Functions/Zftp/zfdir
+++ b/Functions/Zftp/zfdir
@@ -22,6 +22,7 @@
 emulate -L zsh
 setopt extendedglob
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfdir:
 local file opt optlist redir i newargs force
 local curdir=$zfconfig[curdir_$ZFTP_SESSION]
 local otherdir=$zfconfig[otherdir_$ZFTP_SESSION]
diff --git a/Functions/Zftp/zfgcp b/Functions/Zftp/zfgcp
index 916a5f7b6..33b34ac17 100644
--- a/Functions/Zftp/zfgcp
+++ b/Functions/Zftp/zfgcp
@@ -16,6 +16,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfgcp:
 local opt remlist rem loc opt_G opt_t
 integer stat do_close
 
diff --git a/Functions/Zftp/zfget b/Functions/Zftp/zfget
index cb058204d..5207fcfee 100644
--- a/Functions/Zftp/zfget
+++ b/Functions/Zftp/zfget
@@ -19,6 +19,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfget:
 local loc rem opt remlist opt_G opt_t opt_c
 integer stat do_close
 
diff --git a/Functions/Zftp/zfgoto b/Functions/Zftp/zfgoto
index 57651e383..7128cafe2 100644
--- a/Functions/Zftp/zfgoto
+++ b/Functions/Zftp/zfgoto
@@ -8,6 +8,7 @@
 
 emulate -L zsh
 setopt extendedglob
+[[ $curcontext = :zf*: ]] || local curcontext=:zfgoto:
 
 # Set ZFTP_BMFILE if not already set.  This should agree with
 # the corresponding line in zfmark.
diff --git a/Functions/Zftp/zfhere b/Functions/Zftp/zfhere
index 43e599d3a..3f6ca0e3d 100644
--- a/Functions/Zftp/zfhere
+++ b/Functions/Zftp/zfhere
@@ -1,5 +1,6 @@
 # function zfhere {
 # Change to the directory corresponding to $PWD on the server.
 # See zfcd for how this works.
+[[ $curcontext = :zf*: ]] || local curcontext=:zfhere:
 zfcd $PWD
 # }
diff --git a/Functions/Zftp/zfinit b/Functions/Zftp/zfinit
index 256ef1d2f..7179b5e3e 100644
--- a/Functions/Zftp/zfinit
+++ b/Functions/Zftp/zfinit
@@ -1,10 +1,19 @@
 emulate -L zsh
 
-[[ $1 = -n ]] || zmodload -e zftp || zmodload -ia zftp
+[[ $1 = -n ]] || zmodload -e zftp || zmodload -ia zftp || return 1
+
+if zmodload -i zutil; then
+  local arr
+  # Set defaults for styles if none set.
+  zstyle -g arr ':zftp:*' progress || zstyle ':zftp:*' progress bar
+  zstyle -g arr ':zftp:*' update   || zstyle ':zftp:*' update   1
+  zstyle -g arr ':zftp:*' titlebar || zstyle ':zftp:*' titlebar true
+  if functions chpwd >&/dev/null && ! zstyle -g arr ':zftp:*' chpwd; then
+    zstyle ':zftp:*' chpwd true
+  fi
 
-if [[ ${+zfconfig} = 0 ]]; then
   typeset -gA zfconfig
-  zfconfig=(progress bar update 1 lastsession default)
+  zfconfig=(lastsession default)
 fi
 
 alias zfcd='noglob zfcd'
@@ -22,7 +31,7 @@ autoload -U zfstat zftp_chpwd zftp_progress zftransfer zftype zfuget zfuput
 # zftp completions: only use these if new-style completion is not
 # active.
 #
-if [[ ${#_patcomps} -eq 0 || ${_patcomps[(i)zf*]} -gt ${#_patcomps} ]]; then
+if [[ ${#_patcomps} -eq 0 || -z ${_patcomps[(i)zf*]} ]]; then
   # only way of getting that noglob out of the way: this is unnecessary with
   # widget-based completion
   setopt completealiases
@@ -55,3 +64,5 @@ if [[ ${#_patcomps} -eq 0 || ${_patcomps[(i)zf*]} -gt ${#_patcomps} ]]; then
   compctl -s '$(zftp session)' -S : -x 'C[0,*:*]' \
     -K zftransfer_match -- zftransfer
 fi
+
+return 0
diff --git a/Functions/Zftp/zfls b/Functions/Zftp/zfls
index e8d3cfb28..252fe75ad 100644
--- a/Functions/Zftp/zfls
+++ b/Functions/Zftp/zfls
@@ -1,6 +1,7 @@
 # function zfls {
 
 emulate -L zsh
+[[ $curcontext = :zf*: ]] || local curcontext=:zfls:
 
 # directory hack, see zfcd
 if [[ $1 = $HOME || $1 = $HOME/* ]]; then
diff --git a/Functions/Zftp/zfmark b/Functions/Zftp/zfmark
index 74cc702ac..49c1538bc 100644
--- a/Functions/Zftp/zfmark
+++ b/Functions/Zftp/zfmark
@@ -7,6 +7,7 @@
 
 emulate -L zsh
 setopt extendedglob
+[[ $curcontext = :zf*: ]] || local curcontext=:zfmark:
 
 # Set ZFTP_BMFILE if not already set.  This should agree with
 # the corresponding line in zfgoto.
diff --git a/Functions/Zftp/zfopen b/Functions/Zftp/zfopen
index 7c7c945d4..e9ac07b59 100644
--- a/Functions/Zftp/zfopen
+++ b/Functions/Zftp/zfopen
@@ -7,6 +7,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfopen:
 local opt dir opt_1 setparams
 
 while getopts :1 opt; do
diff --git a/Functions/Zftp/zfparams b/Functions/Zftp/zfparams
index faae63251..2a865f004 100644
--- a/Functions/Zftp/zfparams
+++ b/Functions/Zftp/zfparams
@@ -1,6 +1,7 @@
 # function zfparams {
 
 emulate -L zsh
+[[ $curcontext = :zf*: ]] || local curcontext=:zfparams:
 
 if [[ $# -eq 1 && $1 = - ]]; then
   # Delete existing parameter set.
diff --git a/Functions/Zftp/zfpcp b/Functions/Zftp/zfpcp
index 9642688b7..da709b8c7 100644
--- a/Functions/Zftp/zfpcp
+++ b/Functions/Zftp/zfpcp
@@ -14,6 +14,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfpcp:
 local rem loc
 integer stat do_close
 
diff --git a/Functions/Zftp/zfput b/Functions/Zftp/zfput
index 0687163f0..ed81e8129 100644
--- a/Functions/Zftp/zfput
+++ b/Functions/Zftp/zfput
@@ -3,19 +3,64 @@
 # off any directory parts to get the remote filename (i.e. always
 # goes into current remote directory).  Use zfpcp to specify new
 # file name or new directory at remote end.
+#
+# -r means put recursively:  any directories encountered will have
+#    all their contents to arbitrary depth transferred.  Note that
+#    this creates the required directories.  Any files in subdirectories
+#    whose names begin with a `.' will also be included.
 
 emulate -L zsh
 
-local loc rem
-integer stat do_close
+[[ $curcontext = :zf*: ]] || local curcontext=:zfput:
+local opt opt_r
+integer stat do_close abort
+
+while getopts :r opt; do
+  [[ $opt = '?' ]] && print "zfget: bad option: -$OPTARG" && return 1
+  eval "opt_$opt=1"
+done
+(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
 
 zfautocheck
 
-for loc in $*; do
-  rem=${loc:t}
-  zftp put $rem <$loc
-  [[ $? == 0 ]] || stat=$?
-done
+zfput_sub() {
+  local subdirs loc rem
+  integer stat
+  subdirs=()
+
+  for loc in $*; do
+    if [[ -n $opt_r ]]; then
+      if [[ -d $loc ]]; then
+	subdirs=($subdirs $loc)
+	continue
+      else
+	rem=$loc
+      fi
+    else
+      rem=${loc:t}
+    fi
+
+    zftp put $rem <$loc
+    (( $? )) && stat=$?
+    if ! zftp test; then
+      abort=1
+      (( stat )) || stat=1
+      break;
+    fi
+  done
+
+  while (( $#subdirs  && ! abort )); do
+    zftp mkdir ${subdirs[1]}
+    zfput_sub ${subdirs[1]}/*(ND)
+    (( $? )) && stat=$?
+    shift subdirs
+  done
+
+  return $stat
+}
+
+zfput_sub $*
+stat=$?
 
 (( $do_close )) && zfclose
 
diff --git a/Functions/Zftp/zfsession b/Functions/Zftp/zfsession
index 9cd0d918f..516735deb 100644
--- a/Functions/Zftp/zfsession
+++ b/Functions/Zftp/zfsession
@@ -3,6 +3,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfsession:
 local opt opt_l opt_v opt_o opt_d hadopts
 
 while getopts ":lovd" opt; do
diff --git a/Functions/Zftp/zfstat b/Functions/Zftp/zfstat
index 6945da99b..4116240c3 100644
--- a/Functions/Zftp/zfstat
+++ b/Functions/Zftp/zfstat
@@ -6,6 +6,7 @@
 setopt localoptions unset
 unsetopt ksharrays
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfstat:
 local i stat=0 opt opt_v
 
 while getopts :v opt; do
diff --git a/Functions/Zftp/zftp_chpwd b/Functions/Zftp/zftp_chpwd
index 4c23e83bf..cd4560540 100644
--- a/Functions/Zftp/zftp_chpwd
+++ b/Functions/Zftp/zftp_chpwd
@@ -22,14 +22,13 @@ if [[ -z $ZFTP_USER ]]; then
   zfconfig[lastdir_$ZFTP_SESSION]=
 
   # return the display to standard
-  # uncomment the following line if you have a chpwd which shows directories
-  chpwd
+  zstyle -t ":zftp$curcontext" chpwd && chpwd
 else
   [[ -n $ZFTP_PWD ]] && zfconfig[lastdir_$ZFTP_SESSION]=$ZFTP_PWD
   zfconfig[lastloc_$ZFTP_SESSION]="$ZFTP_HOST:$ZFTP_PWD"
   zfconfig[lastuser_$ZFTP_SESSION]="$ZFTP_USER"
   local args
-  if [[ -t 1 && -t 2 ]]; then
+  if [[ -t 1 && -t 2 ]] && zstyle -t ":zftp$curcontext" titlebar; then
     local str=$zfconfig[lastloc_$ZFTP_SESSION]
     [[ ${#str} -lt 70 ]] && str="%m: %~  $str"
     case $TERM in
diff --git a/Functions/Zftp/zftp_progress b/Functions/Zftp/zftp_progress
index b4b639fce..79a20c37e 100644
--- a/Functions/Zftp/zftp_progress
+++ b/Functions/Zftp/zftp_progress
@@ -1,7 +1,7 @@
 # function zftp_progress {
 # Basic progress metre, showing the percent of the file transferred.
 # You want growing bars?  You gottem.
-# zfconfig keys:
+# styles used (context :zftp:zfparent_function:):
 #   progress
 #       empty or `none'                  no progress meter
 #       `bar'                            use a growing bar of inverse video
@@ -11,16 +11,17 @@
 #   update
 #       Minimum time in seconds between updates of the progress display.
 
-# Don't show progress unless stderr is a terminal
-[[ ! -t 2 || ${zfconfig[progress]} = (|none) ]] && return 0
+local style update=1
 
-# Tunable parameters.
-# How many seconds to wait before printing an updated progress report.
-integer update=${zfconfig[update]:-1}
 # What style: either bar for growing bars, or anything else for simple
 # percentage.  For bar we need to have the terminal width in COLUMNS,
 # which is often set automatically, but you never know.
-local style=${zfconfig[progress]}
+zstyle -s ":zftp$curcontext" progress style
+# How many seconds to wait before printing an updated progress report.
+zstyle -s ":zftp$curcontext" update update
+
+# Don't show progress unless stderr is a terminal
+[[ ! -t 2 || $style = (|none) ]] && return 0
 
 if [[ -n $ZFTP_TRANSFER ]]; then
   # avoid a `parameter unset' message
diff --git a/Functions/Zftp/zftransfer b/Functions/Zftp/zftransfer
index 929f099d2..aca5e2ba7 100644
--- a/Functions/Zftp/zftransfer
+++ b/Functions/Zftp/zftransfer
@@ -4,6 +4,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zftransfer:
 local sess1 sess2 file1 file2 oldsess=${ZFTP_SESSION}
 
 if [[ $# -ne 2 ]]; then
@@ -39,7 +40,9 @@ zfautocheck || return 1
 # the size from the pipe --- and if it does, it's probably wrong.
 # To avoid that, try to get the size and set it for the progress to
 # see.
-if [[ $zfconfig[progress] != none ]]; then
+local style
+zstyle -s ':zftp:zftransfer:' progress style
+if [[ -n $style && $style != none ]]; then
   local ZFTP_TSIZE array tmpfile=${TMPPREFIX}zft$$
   zftp remote $file1 >$tmpfile 2>/dev/null
   array=($(<$tmpfile))
@@ -49,7 +52,7 @@ fi
 
 # We do the RHS of the pipeline in a subshell, too, so that
 # the LHS can get SIGPIPE when it exits.
-{ zfconfig[progress]=none
+{ zstyle '*' progress none
   zftp get $file1 } |
 ( zftp session $sess2
   zfautocheck && zftp put $file2 )
diff --git a/Functions/Zftp/zftype b/Functions/Zftp/zftype
index c3b93b7a0..e6e337913 100644
--- a/Functions/Zftp/zftype
+++ b/Functions/Zftp/zftype
@@ -1,5 +1,6 @@
 # function zftype {
 local type zftmp=${TMPPREFIX}zftype$$
+[[ $curcontext = :zf*: ]] || local curcontext=:zftype:
 
 zfautocheck -d
 
diff --git a/Functions/Zftp/zfuget b/Functions/Zftp/zfuget
index 955c48f4a..3cd17bc2e 100644
--- a/Functions/Zftp/zfuget
+++ b/Functions/Zftp/zfuget
@@ -25,6 +25,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfuget:
 local loc rem locstats remstats doit tmpfile=${TMPPREFIX}zfuget$$
 local rstat remlist opt opt_v opt_s opt_G opt_t
 integer stat do_close
diff --git a/Functions/Zftp/zfuput b/Functions/Zftp/zfuput
index cb179052c..456f3f1e0 100644
--- a/Functions/Zftp/zfuput
+++ b/Functions/Zftp/zfuput
@@ -11,6 +11,7 @@
 
 emulate -L zsh
 
+[[ $curcontext = :zf*: ]] || local curcontext=:zfuput:
 local loc rem locstats remstats doit tmpfile=${TMPPREFIX}zfuput$$
 local rstat opt opt_v opt_s
 integer stat do_close