1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-30 17:50:58 +01:00

zsh-workers/7632

This commit is contained in:
Tanaka Akira 1999-09-02 16:44:59 +00:00
parent 8b3e5404ce
commit 6e1759433b
5 changed files with 113 additions and 31 deletions

View file

@ -15,6 +15,10 @@
# a successful open.
local lastsession=$zflastsession
# Unset the delay counter from the progress meter in case there was an
# abnormal exit.
(( ${+zftpseconds} )) && unset zftpseconds
if [[ -z $ZFTP_HOST ]]; then
zfopen || return 1
[[ $1 = *d* ]] || do_close=1

View file

@ -2,6 +2,11 @@ emulate -L zsh
[[ $1 = -n ]] || zmodload -e zftp || zmodload -ia zftp
if [[ ${+zfconfig} = 0 ]]; then
typeset -gA zfconfig
zfconfig=(progress bar update 1)
fi
alias zfcd='noglob zfcd'
alias zfget='noglob zfget'
alias zfls='noglob zfls'
@ -13,15 +18,15 @@ autoload -U zfdir zfgcp zfget zfget_match zfgoto zfhere zfinit zfls
autoload -U zfmark zfopen zfparams zfpcp zfput zfrglob zfrtime zfstat
autoload -U zftp_chpwd zftp_progress zftype zfuget zfuput
# only way of getting that noglob out of the way: this is unnecessary with
# widget-based completion and can be commented out.
setopt completealiases
#
# zftp completions: only use these if new-style completion is not
# active.
#
if [[ ${#_patcomps} -eq 0 || ${_patcomps[(i)zf*]} -gt ${#_patcomps} ]]; then
# only way of getting that noglob out of the way: this is unnecessary with
# widget-based completion
setopt completealiases
compctl -f -x 'p[1]' \
-k '(open params user login type ascii binary mode put putat
get getat append appendat ls dir local remote mkdir rmdir delete

View file

@ -9,7 +9,8 @@
# stick with a single directory. This is the default.
# (2) Use remote globbing, i.e. pass it to ls at the site.
# Faster, but only works with UNIX, and only basic globbing.
# We do this if $zfrglob is non-null.
# We do this if zfconfig[remote_glob] (or $zfrglob for
# backward compatibility) is non-null.
# There is only one argument, the variable containing the
# pattern to be globbed. We set this back to an array containing
@ -20,6 +21,10 @@ setopt extendedglob
local pat dir nondir files i
if [[ -n ${zfconfig[remote_glob]} ]]; then
local zfrglob=1
fi
eval pat=\$$1
# Check if we really need to do anything. Look for standard

View file

@ -1,18 +1,51 @@
# function zftp_progress {
# Basic progress metre, showing the percent of the file transferred.
# You want growing bars? You gotta write growing bars.
# You want growing bars? You gottem.
# zfconfig keys:
# progress
# empty or `none' no progress meter
# `bar' use a growing bar of inverse video
# `percent' or other non-blank show the percentage transferred
# If size of remote file is not available, `bar' or `percent' just show
# bytes.
# update
# Minimum time in seconds between updates of the progress display.
# Don't show progress unless stderr is a terminal
[[ ! -t 2 ]] && return 0
[[ ! -t 2 || ${zfconfig[progress]} = (|none) ]] && return 0
if [[ $ZFTP_TRANSFER = *F ]]; then
print 1>&2
elif [[ -n $ZFTP_TRANSFER ]]; then
# 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]}
if [[ -n $ZFTP_TRANSFER ]]; then
# avoid a `parameter unset' message
[[ $ZFTP_TRANSFER != *F ]] &&
(( ${+zftpseconds} )) && (( SECONDS - zftpseconds < update )) && return
if [[ -n $ZFTP_SIZE ]]; then
local frac="$(( ZFTP_COUNT * 100 / ZFTP_SIZE ))%"
print -n "\r$ZFTP_FILE ($ZFTP_SIZE bytes): $ZFTP_TRANSFER $frac" 1>&2
if [[ $style = bar && ${+COLUMNS} = 1 && $COLUMNS -gt 0 ]]; then
if (( ! ${+zftpseconds} )); then
print "$ZFTP_FILE ($ZFTP_SIZE bytes): $ZFTP_TRANSFER" 1>&2
fi
integer maxwidth=$(( COLUMNS - 7 ))
local width="$(( ZFTP_COUNT * maxwidth / ZFTP_SIZE ))"
print -nP "\r%S${(l:width:):-}%s${(l:maxwidth-width:):-}: ${frac}%%" 1>&2
else
print -n "\r$ZFTP_FILE ($ZFTP_SIZE bytes): $ZFTP_TRANSFER $frac" 1>&2
fi
else
print -n "\r$ZFTP_FILE: $ZFTP_TRANSFER $ZFTP_COUNT" 1>&2
fi
if [[ $ZFTP_TRANSFER = *F && ${+zftpseconds} = 1 ]]; then
unset zftpseconds
print 1>&2
else
zftpseconds=$SECONDS
fi
fi
# }