summary refs log tree commit diff
path: root/Completion/Unix/Command/_rsync
blob: ee05f48413480215d3bede40a35787e85d5202fb (plain) (blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#compdef rsync

_rsync_remote_files() {
local suf tag=accounts

if [[ -prefix *::*/ ]]; then
  local remfiles remdispf remdispd

  compset -P '*::*/'

  remfiles=(${(f)"$(rsync ${words[CURRENT]%/*}/)"})

  remdispf=(${remfiles:#d*})
  remdispd=(${(M)remfiles:#d*})

    _wanted files expl 'remote files and directories' \
      compadd -d remdispf ${remdispf##* }

    _wanted files expl 'remote files and directories' \
      compadd -S/ -d remdispd ${remdispd##* }

elif [[ -prefix 1 *:: ]]; then
  local remfiles remmodules

  compset -P 1 '*::'

  remfiles=(${(f)"$(rsync ${words[CURRENT]%::*}::)"})

  remmodules=(${remfiles/[ 	]#/:})

  _describe "remote modules" remmodules -S/

elif [[ -prefix 1 *: ]]; then
  local remfiles remdispf remdispd slash

  compset -P 1 '*:'

  if zstyle -T ":completion:${curcontext}:" remote-access; then
    slash=/
    remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${${${words[CURRENT
]#*:}:h}/${slash}(#e)/}/\* 2>/dev/null)"})

    remdispf=(${remfiles:#*/})
    remdispd=(${(M)remfiles:#*/})

    _wanted files expl 'remote files and directories' \
      compadd -d remdispf ${${remfiles:#*/}/[*=@|](#e)/}

    _wanted files expl 'remote files and directories' \
      compadd -S/ -d remdispd ${${(M)remfiles:#*/}/${slash}(#e)/}
  else
    _message -e remote-files 'remote files'
  fi

elif [[ -prefix 1 *@ ]]; then
  local user=${PREFIX%%@*}

  compset -P 1 '*@'
  compset -S ':*' || suf=":"

  _wanted -C user-at hosts expl "host for $user" \
      _combination -s '[:@]' "${tag}" users-hosts users="$user" hosts -S "$suf" "$@" -
else
  if compset -S '@*'; then
    _wanted users expl "user" \
	_combination -s '[:@]' "${tag}" users-hosts users -q "$@" -
  else
    _alternative 'user:users:_users -S @' 'host:hosts:_hosts -S:'
  fi
fi

}

_rsync_files() {
  _alternative "file:files:_files" "remote-files:remote files:_rsync_remote_files"
}

_arguments -s \
  '*: :_rsync_files' \
  '*'{-v,--verbose}'[increase verbosity]' \
  '(-q --quiet)'{-q,--quiet}'[show less information during transfer]' \
  '(-c --checksum)'{-c,--checksum}'[always checksum]' \
  '(-a --archive)'{-a,--archive}'[archive mode]' \
  '(-r --recursive)'{-r,--recursive}'[recurse into directories]' \
  '(-E --relative)'{-R,--relative}'[use relative path names]' \
  '(-b --backup)'{-b,--backup}'[make backups]' \
  '--backup-dir[make backups into specified directory]:backup directory:_directories' \
  '--suffix=[override backup suffix]:suffix' \
  '(-u --update)'{-u,--update}'[update only]' \
  '(-l --links)'{-l,--links}'[copy symlinks as symlinks]' \
  '(-L --copy-links)'{-L,--copy-links}'[treat soft links like regular files]' \
  '--copy-unsafe-links[copy links outside the source tree]' \
  '--safe-links[ignore links outside the destination tree]' \
  '(-H --hard-links)'{-H,--hard-links}'[preserve hard links]' \
  '(-p --perms)'{-p,--perms}'[preserve permissions]' \
  '(-o --owner)'{-o,--owner}'[preserve owner]' \
  '(-g --group)'{-g,--group}'[preserve group]' \
  '(-D --devices)'{-D,--devices}'[preserve devices]' \
  '(-t --times)'{-t,--times}'[preserve times]' \
  '(-S --sparse)'{-S,--sparse}'[handle sparse files efficiently]' \
  '(-n --dry-run)'{-n,--dry-run}'[show what would have been transferred]' \
  '(-W --whole-file --no-whole-file)'{-W,--whole-file}'[copy whole files]' \
  '(-W --whole-file)--no-whole-file[always use incremental rsync algorithm]' \
  '(-x --one-file-system)'{-x,--one-file-system}'[do not cross filesystem boundaries]' \
  '(-B --block-size)'{-B,--block-size=}'[checksum blocking size]:block size' \
  '(-e --rsh)'{-e,--rsh}'[rsh command]:remote command:(rsh ssh)' \
  '--rsync-path=[specify path to rsync on the remote machine]:remote command:' \
  '(-C --cvs-exclude)'{-C,--cvs-exclude}'[autoignore files in the same way as CVS]' \
  '--existing[only update files that already exist]' \
  '--ignore-existing[ignore files that already exist on the receiving side]' \
  '--delete[delete files that do not exist on the sending side]' \
  '--delete-excluded[also delete excluded files on the receiving side]' \
  '--delete-after[perform delete after transferring]' \
  '--ignore-errors[delete even if there are IO errors]' \
  '--max-delete=[do not delete more than NUM files]:number:' \
  '(-P)--partial[keep partially transferred files]' \
  '--force[force deletion of directories even if not empty]' \
  '--numeric-ids[do not map uid/gid values by user/group name]' \
  '--timeout=[set IO timeout in seconds]:seconds:' \
  '(-I --ignore-times)'{-I,--ignore-times}'[do not exclude files that match length and time]' \
  '--size-only[only use file size when determining if a file should be transferred]' \
  '--modify-window=[timestamp window for file match]:seconds:' \
  '(-T --temp-dir)'{-T,--temp-dir=}'[create temporary files in specified directory]:directory:_files -/' \
  '--compare-dest=[also compare destination files relative to specified directory]:directory:_files -/' \
  '(--partial --progress)-P[equivalent to --partial --progress]' \
  '(-z --compress)'{-z,--compress}'[compress file data]' \
  '--exclude=[exclude files matching pattern]:pattern:' \
  '--exclude-from=[exclude patterns listed in file]:file:_files' \
  '--include=[do not exclude files matching pattern]:pattern:' \
  '--include-from=[do not exclude patterns listed in file]:file:_files' \
  '--version[print version number]' \
  '--daemon[run as a rsync daemon]' \
  '--no-detach[do not detach from the parent]' \
  '--address=[bind to the specified address]:address:_hosts' \
  '--config=[specify alternate rsyncd.conf file]:file:_files' \
  '--port=[specify alternate rsyncd port number]:port:' \
  '--blocking-io[use blocking IO for the remote shell]' \
  '--no-blocking-io[turn off blocking IO when it is the default]' \
  '--stats[give some file transfer stats]' \
  '(-P)--progress[show progress during transfer]' \
  '--log-format=[log file transfers using specified format]:format:' \
  '--password-file=[get password from file]:file:_files' \
  '--bwlimit=[limit bandwidth]:kbytes per second:' \
  '--read-batch=[read batch file]:ext:' \
  '--write-batch[write batch file]' \
  '(-)'{-h,--help}'[display help information]' \
  '-4[prefer IPv4]' \
  '-6[prefer IPv6]' \
     -- '*=COMMAND*:command:_command' \
	'*=FILE*:file:_files' \
	'*=DIR*:directory:_files -/'