zsh-workers
 help / color / mirror / code / Atom feed
0d8355bfb49db976a7abcfb8fba1777598d7a346 blob 2683 bytes (raw)

  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
 
#compdef rlogin rsh remsh=rsh rcp

_rcp_remote_files () {
  # There should be coloring based on all the different ls -F classifiers.
  local expl remfiles remdispf remdispd suf ret=1

  if zstyle -T ":completion:${curcontext}:" remote-access; then
    remfiles=(${(M)${(f)"$(rsh ${IPREFIX%:} ls -d1F ${(Q)PREFIX%%[^./][^/]#}\* 2>/dev/null)"}%%[^/]#(|/)})
    compset -P '*/'
    compset -S '/*' || suf='remote file'

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

    _tags files
    while _tags; do
      while _next_label files expl ${suf:-remote directory}; do
        [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
	    ${(q)remdispf%[*=@|]} && ret=0 
	compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
	    ${(q)remdispd%/} && ret=0
      done
      (( ret )) || return 0
    done
  else
    _message -e remote-files 'remote file'
  fi
}

_rlogin () {
  case "$service" in
  rlogin)
    _arguments -s \
      '-8[allow 8-Bit data]' \
      '-e-[specify escape character]:escape character:' \
      '-l[specify login user name]:login as:_rlogin_users' \
      ':remote host name:_rlogin_hosts'
    ;;
  rsh|remsh)
    local context state line ret=1
    typeset -A opt_args

    _arguments -s \
      '-n[ignore stdin]' \
      '-l[specify login user name]:login as:_rlogin_users' \
      ':remote host name:_rlogin_hosts' \
      '(-):command: _command_names -e' \
      '*::command:->command' && ret=0

    if [[ -n "$state" ]]; then
      shift 1 words
      (( CURRENT-- ))
      _normal && ret=0
    fi
    return ret
    ;;
  rcp)
    local curcontext="$curcontext" state line ret=1 expl
    typeset -A opt_args

    _arguments -C -s \
      '-p[preserve modification times]' \
      '-r[recursively copy directories]' \
      '*:files:->files' && ret=0

    if [[ -n "$state" ]]; then
      if compset -P '*:'; then
	_rcp_remote_files && ret=0
      elif compset -P '*@'; then
        _wanted hosts expl host _rlogin_hosts -S: && ret=0
      else
        _alternative \
	    'files:: _files' \
	    'hosts:: _rlogin_all_hosts -S:' \
	    'users:: _rlogin_users -qS@' && ret=0
      fi
    fi
    return ret
    ;;    
  esac
}

_rlogin_users () {
  _tags users && _combination -s '[:@]' my-accounts users-hosts users "$@"
}

_rlogin_hosts () {
  _tags hosts &&
      if [[ "$IPREFIX" == *@ ]]; then
        _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
      else
        _combination -s '[:@]' my-accounts users-hosts \
            ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
      fi
}

_rlogin_all_hosts () {
  _tags hosts && _combination -s '[:@]' my-accounts users-hosts hosts "$@"
}

_rlogin "$@"
debug log:

solving 0d8355b ...
found 0d8355b in https://git.vuxu.org/mirror/zsh/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).