add trash-d completion

This commit is contained in:
mirsella 2023-07-09 17:36:36 +02:00
parent 5328eb7c01
commit 1bef992b46
1 changed files with 49 additions and 0 deletions

49
src/_trash Normal file
View File

@ -0,0 +1,49 @@
#compdef trash
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for trash-d (https://github.com/rushsteve1/trash-d).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * mirsella (github.com/mirsella)
#
# ------------------------------------------------------------------------------
declare -a args opts=( -A '-*' )
args=(
'(-d --dir)'{-d,--dir}'[Remove empty directories]'
'(-r --recursive)'{-r,--recursive}'[Delete directories and their contents]'
'(-v --verbose)'{-v,--verbose}'[Print more information]'
'(-i --interactive)'{-i,--interactive}'[Ask before each deletion]'
'(-I --interactive-once)'{-I,--interactive-once}'[Ask once if deleting 3 or more]'
'(-f --force)'{-f,--force}'[Don'\''t prompt and ignore errors]'
'--version[Output the version and exit]'
'--list[List out the files in the trash]'
'--orphans[List orphaned files in the trash]'
'--restore[Restore a file from the trash]'
'--delete[Delete a file from the trash]'
'--empty[Empty the trash bin]'
'--rm[Escape hatch to permanently delete a file]'
'(-h --help)'{-h,--help}'[This help information]'
'*:: :->file'
)
local curcontext=$curcontext state line ret=1
declare -A opt_args
_arguments -C -s -S $opts \
$args && ret=0
case $state in
(file)
(( CURRENT > 0 )) && line[CURRENT]=()
line=( ${line//(#m)[\[\]()\\*?#<>~\^\|]/\\$MATCH} )
_files -F line && ret=0
;;
esac
return $ret