about summary refs log tree commit diff
path: root/Functions/Zftp/zftp_progress
blob: e2b5084c48e1715b2c0098238abbdac50dd54756 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# function zftp_progress {
# Basic progress metre, showing the percent of the file transferred.
# You want growing bars?  You gotta write growing bars.

# Don't show progress unless stderr is a terminal
[[ ! -t 2 ]] && return 0

if [[ $ZFTP_TRANSFER = *F ]]; then
  print 1>&2
elif [[ -n $ZFTP_TRANSFER ]]; then
  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
  else
    print -n "\r$ZFTP_FILE: $ZFTP_TRANSFER $ZFTP_COUNT" 1>&2
  fi
fi
# }