1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-01 21:51:40 +02:00

43043: Improve comm/sed completion

This commit is contained in:
dana 2018-06-17 20:38:15 -05:00
parent 796637362a
commit ed2f4d6840
3 changed files with 21 additions and 12 deletions

View file

@ -1,5 +1,8 @@
2018-06-17 dana <dana@dana.is>
* 43043: Completion/Unix/Command/_comm,
Completion/Unix/Command/_sed: Improve comm/sed completion
* 43039: Src/Modules/parameter.mdd: Mark functions_source (et al.)
for auto-loading

View file

@ -1,6 +1,6 @@
#compdef comm gcomm
local -a args
local -a args aopts=( -A '-*' )
args=(
'-1[suppress lines unique to first file]'
@ -11,10 +11,13 @@ args=(
)
if _pick_variant gnu=GNU unix --version; then
aopts=( )
args+=(
'(--nocheck-order)--check-order[check input is correctly sorted]'
"(--check-order)--nocheck-order[don't check input is correctly sorted]"
'--output-delimiter=:delimiter'
'--output-delimiter=[specify column delimiter]:delimiter'
'--total[display summary]'
'(-z --zero-terminated)'{-z,--zero-terminated}'[use NUL as line delimiter]'
'(- : *)--version[display version information]'
'(- : *)--help[display help information]'
)
@ -24,4 +27,4 @@ elif [[ $OSTYPE = (openbsd|netbsd)* ]]; then
args+=( '-f[case insensitive comparison of lines]' )
fi
_arguments -s $args
_arguments -s -S $aopts : $args

View file

@ -1,11 +1,12 @@
#compdef sed gsed psed s2p
local args inplace extended
local inplace extended
local -a args aopts=( -A '-*' )
args=(
'(-n --quiet --silent)'{-n,--quiet,--silent}'[suppress automatic printing of pattern space]'
'(1)*'{-e,--expression=-}'[specify sed commands to run]:sed script'
'(1)*'{-f,--file=-}'[add contents of file to commands to run]:file:_files'
'(1)*'{-e+,--expression=}'[specify sed commands to run]:sed script'
'(1)*'{-f+,--file=}'[add contents of file to commands to run]: :_files'
'(-e)1: :_guard "^-*" sed script'
'*:input file:_files'
)
@ -18,11 +19,12 @@ if [[ $service = (psed|s2p) ]]; then
'-a[delay opening files listed with w function]'
)
elif _pick_variant gnu=GNU unix --version; then
aopts=( )
args+=(
'--follow-symlinks[follow symlinks when processing in place]'
'(-i --in-place)'{-i-,--in-place=-}$inplace
'(-i --in-place)'{-i+,--in-place=}$inplace
'(-c --copy)'{-c,--copy}'[copy instead of rename when shuffling files in in-place mode]'
'(-l --line-length)'{-l,--line-length=-}'[specify line-wrap length for the l command]'
'(-l --line-length)'{-l+,--line-length=}'[specify line-wrap length for the l command]'
'(-r)--posix[disable GNU extensions]'
'(-E -r --regexp-extended)'{-E,-r,--regexp-extended}$extended
'(-s --separate)'{-s,--separate}'[consider files separately instead of as a combined stream]'
@ -37,20 +39,21 @@ else
case $OSTYPE in
openbsd*|freebsd*|netbsd*|darwin*|dragonfly*)
args+=(
'(-r -E)'{-r,-E}$extended
'(-r -E)'-E$extended
'-a[delay opening files listed with w function]'
)
;|
darwin*|freebsd*|netbsd*|openbsd*) args+=( '-i'$inplace ) ;|
openbsd*|freebsd*|netbsd*|dragonfly*) args+=( '(-r -E)'-r$extended ) ;|
darwin*|freebsd*|netbsd*|openbsd*) args+=( '-i+'$inplace ) ;|
darwin*|freebsd*|netbsd*) args+=( '-l[make output line buffered]' ) ;|
freebsd*) args+=( '-u[disable data buffering]' ) ;|
freebsd*|netbsd*)
args+=(
'-I[edit files in-place, treating all files as a single input stream]::suffix for backup'
'-I+[edit files in-place, treating all files as a single input stream]::suffix for backup'
)
;;
openbsd*) args+=( '-u[make output line buffered]' ) ;;
esac
fi
_arguments -s "$args[@]"
_arguments -s -S $aopts : "$args[@]"