File: zftp_chpwd

package info (click to toggle)
zsh-beta 4.3.0-dev-1%2B20050424-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 18,240 kB
  • ctags: 6,564
  • sloc: ansic: 79,241; sh: 4,874; perl: 748; makefile: 676; awk: 341; sed: 16
file content (42 lines) | stat: -rw-r--r-- 1,386 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# function zftp_chpwd {
# You may want to alter chpwd to call this when $ZFTP_USER is set.

# If the directory really changed...
if [[ $ZFTP_PWD != $zfconfig[lastdir_$ZFTP_SESSION] ]]; then
  # ...and also empty the stored directory listing cache.
  # As this function is called when we close the connection, this
  # is the only place we need to do these two things.
  local curdir=$zfconfig[curdir_$ZFTP_SESSION]
  [[ -n $curdir && -f $curdir ]] && rm -f $curdir
  zfconfig[otherargs_$ZFTP_SESSION]=
  zffcache -d
fi

if [[ -z $ZFTP_USER ]]; then
  # last call, after an FTP logout

  # delete the non-current cached directory
  [[ -n $zfotherdir && -f $zfotherdir ]] && rm -f $zfotherdir

  # don't keep lastdir between opens (do keep lastloc)
  zfconfig[lastdir_$ZFTP_SESSION]=

  # return the display to standard
  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 ]] && zstyle -t ":zftp$curcontext" titlebar; then
    local str=$zfconfig[lastloc_$ZFTP_SESSION]
    [[ ${#str} -lt 70 ]] && str="%m: %~  $str"
    case $TERM in
      sun-cmd) print -Pn "\033]l$str\033\\"
	       ;;
      *xterm*|rxvt|dtterm|Eterm|kterm) print -Pn "\033]2;$str\a"
	     ;;
    esac
  fi
fi
# }