about summary refs log tree commit diff
path: root/Completion/Zsh/Context/_redirect
blob: 5e454014bea1d850f0ad620681e7cfe9af7719b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#compdef -redirect-

# This searches for `<command-name>:<redir-op>' and `<redir-op>', where
# `<redir-op>' is something like `<' or `2>'.

local strs _comp_command1 _comp_command2

_set_command

strs=( "$compstate[redirect]" )

if [[ -n "$_comp_command1" ]]; then
  strs=( "${_comp_command1}:$strs[-1]" "$strs[@]" )
  [[ -n "$_comp_command2" ]] && strs=( "${_comp_command2}:$strs[1]" "$strs[@]" )
fi

_dispatch -d redirs "$strs[@]"