Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: new column completion
- X-seq: zsh-workers 42583
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: new column completion
- Date: Thu, 05 Apr 2018 00:35:35 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1522894257; bh=MQukExTKNsTzI6cpCjwjwzpAjHMwo3LAQ8tIx9wtxBI=; h=From:To:Subject:Date:From:Subject; b=D/K/stWKmaHrn27/VHnpSEcWLYmi4pQG15QYMrsrISnzY8uXFLa8A7Z8yePBwTZuKrVEKPGxNNhtci+dRCZcssBuEJC8r9m3VdoWLKdohj4Xw0nN1o+TX/Os1YCIbZlKfuXffQNLXOLB0+YtoOZutgoVWXQT2ZG3A95bge5snpyxqkkHsYbhBKnNPm804zxB9/2tV4GPQCxrt9BJm8tHCebpBAi1KN55JQoqBVKqFrBeO9adQD+/JrVMNIolO/7pnUPJs4FMp6C48h4tbq4nozk4BdVMyvrX2PyO2gbr6YlMZKWkQRw+G855hUFz5bjuY/cQSpkpL2LidoC/eLEsXw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Having been unchanged for years, the util-linux column command has
gained quite a bit of new functionality recently. This now adds
completion for it.
Oliver
diff --git a/Completion/Unix/Command/_column b/Completion/Unix/Command/_column
new file mode 100644
index 000000000..cb67fef37
--- /dev/null
+++ b/Completion/Unix/Command/_column
@@ -0,0 +1,59 @@
+#compdef column
+
+local ret=1
+local -a context state line expl args columns MATCH
+local -i MBEGIN MEND
+local -A opt_args
+
+case $OSTYPE in
+ linux-gnu)
+ args=(
+ '(info json -c --output-width)'{-c+,--output-width=}'[format output to fit display of specified width]:width'
+ + fill
+ '(info table text json -x --fillrows)'{-x,--fillrows}'[fill rows before filling columns]'
+ + table
+ '(info fill -t --table)'{-t,--table}'[create a table]'
+ '(info fill -s --separator)'{-s+,--separator=}'[specify column delimiters in input data]:delimiters'
+ '(info fill -O --table-order)'{-O+,--table-order=}'[specify order of output columns]: :->columns'
+ '(info fill -N --table-columns)'{-N+,--table-columns=}'[specify column names]:names'
+ '(info fill -H --table-hide)'{-H+,--table-hide=}"[don't print specified columns]: :->columns"
+ + text
+ '(info fill json -d --table-noheadings)'{-d,--table-noheadings}"[don't print header]"
+ '(info fill json -E --table-noextreme)'{-E,--table-noextreme}"[specify columns where length can be ignored]: :->columns"
+ '(info fill json -e --table-header-repeat)'{-e,--table-header-repeat}'[repeat header for each page]'
+ '(info fill json -R --table-right)'{-R+,--table-right=}'[right align text in these columns]: :->columns'
+ '(info fill json -T --table-truncate)'{-T+,--table-truncate=}'[truncate text in the columns when necessary]: :->columns'
+ '(info fill json -W --table-wrap)'{-W+,--table-wrap=}'[wrap text in the columns when necessary]: :->columns'
+ '(info fill json -r --tree)'{-r+,--tree=}'[specify column to format tree-like]: :->column'
+ '(info fill json -i --tree-id)'{-i+,--tree-id=}'[specify column containing ID for child-parent relations]: :->column'
+ '(info fill json -p --tree-parent)'{-p+,--tree-parent=}'[specify column containing reference to parent]: :->column'
+ + json
+ '(info fill text -n --table-name -c --output-width)'{-n+,--table-name=}'[specify table name for JSON output]:name'
+ '(info fill text -J --json -c --output-width)'{-J,--json}'[use JSON output format for table]'
+ + info
+ '(- *)'{-h,--help}'[display usage information]'
+ '(- *)'{-V,--version}'[display version information]'
+ )
+ ;;
+ *)
+ args=(
+ '(-t -s)-c+[format output to fit display of specified width]:width'
+ '(-c -x)-t[create a table]'
+ '(-c -x)-s+[specify column delimiters in input data]:delimiters'
+ '(-t -s)-x[fill rows before filling columns]'
+ )
+ ;;
+esac
+
+_arguments -s -S '*:file:_files' $args && ret=0
+
+if [[ -n $state ]]; then
+ columns=( ${(s.,.)${(Q)${opt_args[table--N]:-$opt_args[table---table-columns]}//(#m)\\([\\:])/${MATCH[2]}}} )
+ if (( $#columns )); then
+ ${${(M)state:#*s}:+_sequence} _wanted -C "$context[1]" columns expl column compadd -a - columns && ret=0
+ else
+ _message -e columns "$state"
+ fi
+fi
+
+return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author