about summary refs log tree commit diff
path: root/Completion/Unix/Command/_trash
blob: bef6e58380a8d10c12296eb75544b5df2df7be48 (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
#compdef trash

local variant

_pick_variant -r variant ali='(Rantakari|hasseg)' steven='(Steven|vanZyl)' other --version

case $variant in
  ali)
    # The hidden options here are options to rm that trash silently (and
    # undocumentedly) ignores. Some options are not made mutually exclusive where
    # they technically could be, for compatibility with aliases, etc.
    _arguments -s -S -A '-*' : \
      '!-'{d,f,i,r,P,R,W} \
      '(: * -F -l -v)-e[empty trash]' \
      '-F[use Finder instead of system API]' \
      '(: * -e -F -s -y)-l[list items in trash]' \
      '(: * -F -l -v)-s[securely empty trash]' \
      '-v[increase output verbosity]' \
      '-y[skip confirmation prompts (with -e or -s)]' \
      '*: :_files'
    return
    ;;
  steven)
    local trash_dir="${TRASH_D_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/Trash}/files"

    local -a args=(
      '(-v --verbose)'{-v,--verbose}'[print more information]'

      + options
      '(-d --dir)'{-d,--dir}'[remove empty directories]'
      '(-r -R --recursive)'{-r,-R,--recursive}'[delete directories and their contents]'
      '--rm[permanently delete files]'

      + '(interactive)'
      {-i,--interactive}'[ask before each deletion]'
      {-I,--interactive-once}'[ask before deleting 3 or more files, or deleting recursively]'
      {-f,--force}'[don'\''t prompt and ignore errors]'

      + '(actions)'
      '(options input info interactive)--list[list out the files in the trash]'
      '(options input info interactive)--orphans[list orphaned files in the trash]'
      '(options input info)--restore[restore specified file from the trash]:trashed file:_files -W "$trash_dir"'
      '(options input info)--delete[delete specified file from the trash]:trashed file:_files -W "$trash_dir"'
      '(options input info)--empty[empty the trash bin]'

      + info
      '(- *)'{-h,--help}'[display help information]'
      '(- *)--version[output the version and exit]'

      + input
      '(actions)*: :_files'
    )
    _arguments -s -S : $args
    return
    ;;
  *) _default ;;
esac