+ fix completion for tmux

+ add completion for pfctl

"looks good" sthen@
This commit is contained in:
pea 2009-12-16 15:03:28 +00:00
parent f85afedfdd
commit b9d0ef45fe
4 changed files with 166 additions and 34 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.51 2009/11/13 12:26:40 pea Exp $
# $OpenBSD: Makefile,v 1.52 2009/12/16 15:03:28 pea Exp $
COMMENT= Z shell, Bourne shell-compatible
V= 4.3.10
DISTNAME= zsh-$V
PKGNAME= ${DISTNAME}p0
PKGNAME= ${DISTNAME}p1
CATEGORIES= shells
MAINTAINER= Pierre-Emmanuel Andre <pea@openbsd.org>

View File

@ -0,0 +1,100 @@
$OpenBSD: patch-Completion_BSD_Command__pfctl,v 1.1 2009/12/16 15:03:28 pea Exp $
--- Completion/BSD/Command/_pfctl.orig Thu Dec 10 17:36:31 2009
+++ Completion/BSD/Command/_pfctl Thu Dec 10 17:36:44 2009
@@ -0,0 +1,96 @@
+#compdef pfctl
+
+local pfctl_flush_modifiers pfctl_optimizer_level pfctl_show_modifiers pfctl_tables_command pfctl_debug_level
+
+pfctl_flush_modifiers=(
+ 'all:Flush all'
+ 'info:Flush the filter information'
+ 'nat:Flush the NAT rules'
+ 'osfp:Flush the passive operating system fingerprints'
+ 'queue:Flush the queue rules'
+ 'rules:Flush the filter rules'
+ 'state:Flush the stable table'
+ 'Sources:Flush the source tracking table'
+ 'Tables:Flush the tables'
+)
+
+pfctl_show_modifiers=(
+ 'nat:Show the currently loaded NAT rules'
+ 'queue:Show the currently loaded queue rules'
+ 'rules:Show the currently loaded filter rules'
+ 'Anchors:Show the currently loaded anchors directly attached to the main ruleset'
+ 'state:Show the contents of the state table'
+ 'Sources:Show the contents of the source tracking table'
+ 'info:Show filter information'
+ 'labels:Show per-rule statistics of filter rules with labels'
+ 'timeouts:Show the current global timeouts'
+ 'memory:Show the current pool memory hard limits'
+ 'Tables:Show the list of tables'
+ 'osfp:Show the list of operating system fingerprints'
+ 'Interfaces:Show the list of interfaces and interface drivers available to PF'
+ 'all:Show all except for the lists of interfaces and operating system fingerprints'
+)
+
+pfctl_optimizer_level=(
+ 'none:Disable the ruleset optimizer'
+ 'basic:Enable basic ruleset optimizations'
+ 'profile:Enable basic ruleset optimizations with profiling'
+)
+pfctl_tables_command=(
+ 'kill:Kill a table'
+ 'flush:Flush all addresses of a table'
+ 'add:Add one or more addresses in a table'
+ 'delete:Delete one or more addresses from a table'
+ 'expire:Delete addresses which had their statistics cleared more than number seconds ago'
+ 'replace:Replace the addresses of the table'
+ 'show:Show the content (addresses) of a table'
+ 'test:Test if the given addresses match a table'
+ 'zero:Clear all the statistics of a table'
+ 'load:Load only the table definitions from pf.conf(5)'
+)
+pfctl_debug_level=(
+ "none:Don\'t generate debug messages"
+ 'urgent:Generate debug messages only for serious errors'
+ 'misc:Generate debug messages for various errors'
+ 'loud:Generate debug messages for common conditions'
+)
+_iface() {
+ local pfctl_iface
+ pfctl_iface=($(pfctl -s Interfaces))
+ compadd $pfctl_iface
+}
+_tables() {
+ local pfctl_tables
+ pfctl_tables=($(pfctl -s Tables))
+ compadd $pfctl_tables
+}
+# TODO:
+# Missing -a
+#
+_arguments -s \
+ '-F[Flush the filter parameters specified by modifier]:modifier:(($pfctl_flush_modifiers))' \
+ '-A[Load only the queue rules present in the rule file]' \
+ '-D[Define macro to be set to value]:macro:' \
+ '-d[Disable the packet filter]' \
+ '-e[Enable the packet filter]' \
+ '-f[Load the rules contained in a file]:configuration file:_files' \
+ '-g[Include output helpful for debugging]' \
+ '-h[Help]' \
+ '-i[Restrict the operation to the given interface]:interface:_iface' \
+ '-K[Kill all of the source tracking entries originating from the specified host or network]:host or network:_hosts' \
+ '-k[Kill all of the state entries originating from the specified host or network]:host or network:_hosts' \
+ '-m[Merge in explicitly given options]' \
+ '-N[Load only the NAT rules present in the rule file]' \
+ '-n[Do not actually load rules, just parse them]' \
+ '-O[Load only the options present in the rule file]' \
+ '-o[Control the ruleset optimizer]:level:(($pfctl_optimizer_level))' \
+ '-p[Use the device file device instead of the default /dev/pf]:device:_files' \
+ '-q[Only print errors and warnings]' \
+ '-R[Load only the filter rules present in the rule file]' \
+ '-r[Perform reverse DNS lookups on states when displaying them]' \
+ '-s[Show the filter parameters specified by modifier]:modifier:(($pfctl_show_modifiers ))' \
+ '-T[Specify the command to apply to the table]:command:(($pfctl_tables_command))' \
+ '-t[Specify the name of the table]:table:_tables' \
+ '-v[Produce more verbose output]' \
+ '-x[Set the debug level]:debug level:(($pfctl_debug_level))' \
+ '-z[Clear per-rule statistics]'

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp $
--- Completion/Unix/Command/_tmux.orig Fri Nov 13 10:56:08 2009
+++ Completion/Unix/Command/_tmux Fri Nov 13 10:57:05 2009
@@ -0,0 +1,1461 @@
$OpenBSD: patch-Completion_Unix_Command__tmux,v 1.2 2009/12/16 15:03:28 pea Exp $
--- Completion/Unix/Command/_tmux.orig Thu Dec 10 17:25:18 2009
+++ Completion/Unix/Command/_tmux Thu Dec 10 17:27:19 2009
@@ -0,0 +1,1491 @@
+#compdef tmux
+
+# tmux <http://tmux.sf.net> completion for zsh <http://zsh.sf.net>.
@ -61,6 +61,7 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ new new-session
+ refresh refresh-client
+ rename rename-session
+ showmsgs show-messages
+ source source-file
+ start start-server
+ suspendc suspend-client
@ -68,6 +69,7 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+
+ # windows and panes
+ breakp break-pane
+ capturep capture-pane
+ displayp display-panes
+ downp down-pane
+ findw find-window
@ -109,7 +111,8 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ showw show-window-options
+
+ # environment
+ #no aliases so far in this category
+ setenv set-environment
+ showenv show-environment
+
+ # status line
+ confirm confirm-before
@ -193,6 +196,16 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ _arguments ${args}
+}
+
+function _tmux-capture-pane() {
+ [[ -n ${tmux_describe} ]] && print "Capture the contents of a pane to a buffer" && return
+ local -a args
+ args=(
+ '-b[Choose target buffer]:target buffer:__tmux-buffers'
+ '-t[Choose source pane]:source pane:__tmux-panes'
+ )
+ _arguments ${args}
+}
+
+function _tmux-choose-client() {
+ [[ -n ${tmux_describe} ]] && print "Put a window into client choice mode" && return
+ __tmux-choose-stuff
@ -338,6 +351,7 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ [[ -n ${tmux_describe} ]] && print "Display a message in the status line" && return
+ local -a args
+ args=(
+ '-p[Print message to stdout]'
+ '-t[Choose a target client]:clients:__tmux-clients'
+ '*:: :->msg'
+ )
@ -838,27 +852,19 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+
+function _tmux-set-option() {
+ [[ -n ${tmux_describe} ]] && print "Set a session option" && return
+ local mode
+ local -a args
+ args=(
+ '-a[Append to string options]'
+ '-g[Set a global session option]'
+ '-u[Unset a non-global option]'
+ '-w[Change window (not session) options]'
+ '-t[Choose a target session]:target session:__tmux-sessions'
+ '*:: :->name_or_value'
+ )
+ __tmux-got-option-already -w && mode=window || mode=session
+ _arguments -C ${args}
+
+ case ${state} in
+ name_or_value)
+ if (( CURRENT == 1 )); then
+ __tmux-options
+ elif (( CURRENT == 2 )); then
+ __tmux-option-guard 'session' ${words[1]}
+ else
+ __tmux-nothing-else
+ fi
+ ;;
+ esac
+ __tmux-options-complete ${mode} ${state}
+}
+
+function _tmux-set-window-option() {
@ -872,18 +878,7 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ '*:: :->name_or_value'
+ )
+ _arguments -C ${args}
+
+ case ${state} in
+ name_or_value)
+ if (( CURRENT == 1 )); then
+ __tmux-window-options
+ elif (( CURRENT == 2 )); then
+ __tmux-option-guard 'window' ${words[1]}
+ else
+ __tmux-nothing-else
+ fi
+ ;;
+ esac
+ __tmux-options-complete window ${state}
+}
+
+function _tmux-show-buffer() {
@ -927,6 +922,12 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ _arguments ${args}
+}
+
+function _tmux-show-messages() {
+ [[ -n ${tmux_describe} ]] && print "Show client"\'"s message log" && return
+ args=('-t[Choose target client]:client:__tmux-clients')
+ _arguments ${args}
+}
+
+function _tmux-show-options() {
+ [[ -n ${tmux_describe} ]] && print "Show session options" && return
+ local -a args
@ -1006,8 +1007,8 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ [[ -n ${tmux_describe} ]] && print "Switch the client to another session" && return
+ local -a args
+ args=(
+ '-c[Choose a target client]:client:__tmux-key-clients'
+ '-t[Choose a target window]:window:__tmux-key-windows'
+ '-c[Choose a target client]:client:__tmux-clients'
+ '-t[Choose a target window]:window:__tmux-windows'
+ )
+ _arguments ${args}
+}
@ -1128,6 +1129,11 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ done
+}
+
+function __tmux-got-option-already() {
+ [[ -n ${(M)words:#$1} ]] && return 0
+ return 1
+}
+
+function __tmux-key-tables() {
+ local expl
+ local -a tables
@ -1182,6 +1188,7 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ 'message-attr:__tmux-attributes'
+ 'message-bg:__tmux-colours'
+ 'message-fg:__tmux-colours'
+ 'message-limit:'${int_guard}
+ 'mouse-select-pane:DESC:on off'
+ 'prefix:MSG:comma-seperated key list'
+ 'repeat-time:'${int_guard}
@ -1237,7 +1244,9 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ 'window-status-current-attr:__tmux-attributes'
+ 'window-status-current-bg:__tmux-colours'
+ 'window-status-current-fg:__tmux-colours'
+ 'window-status-current-format:MSG:status format string'
+ 'window-status-fg:__tmux-colours'
+ 'window-status-format:MSG:status format string'
+ 'xterm-keys:DESC:on off'
+ )
+ fi
@ -1284,6 +1293,7 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ 'message-attr:Set status line message attributes'
+ 'message-bg:Set status line message background colour'
+ 'message-fg:Set status line message foreground colour'
+ 'message-limit:Set size of message log per client'
+ 'mouse-select-pane:Make mouse clicks select window panes'
+ 'prefix:Comma seperated line of keys accepted as prefix key'
+ 'repeat-time:Time for multiple commands without prefix-key presses'
@ -1317,6 +1327,24 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ _describe -t tmux-options 'tmux option' tmux_options
+}
+
+function __tmux-options-complete() {
+ local mode="$1" state="$2"
+
+ case ${state} in
+ name_or_value)
+ if (( CURRENT == 1 )) && [[ ${mode} == 'session' ]]; then
+ __tmux-options
+ elif (( CURRENT == 1 )) && [[ ${mode} == 'window' ]]; then
+ __tmux-window-options
+ elif (( CURRENT == 2 )); then
+ __tmux-option-guard ${mode} ${words[1]}
+ else
+ __tmux-nothing-else
+ fi
+ ;;
+ esac
+}
+
+function __tmux-panes() {
+ local expl line
+ local -i num
@ -1380,7 +1408,9 @@ $OpenBSD: patch-Completion_Unix_Command__tmux,v 1.1 2009/11/13 12:26:40 pea Exp
+ 'window-status-current-attr:Set status line attributes for active window'
+ 'window-status-current-bg:Set status line background for active window'
+ 'window-status-current-fg:Set status line foreground for active window'
+ 'window-status-current-format:Set status line format for active window'
+ 'window-status-fg:Set status line foreground for a window'
+ 'window-status-format:Set status line format for all but the active window'
+ 'xterm-keys:Generate xterm-style function key sequences'
+ )
+ _describe -t tmux-window-options 'tmux window option' tmux_window_options

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST,v 1.28 2009/11/13 12:26:40 pea Exp $
@comment $OpenBSD: PLIST,v 1.29 2009/12/16 15:03:28 pea Exp $
@pkgpath shells/zsh,-main
@shell bin/zsh
%%SHARED%%
@ -393,6 +393,8 @@ share/zsh/${V}/functions/_perl
share/zsh/${V}/functions/_perl_basepods
share/zsh/${V}/functions/_perl_modules
share/zsh/${V}/functions/_perldoc
share/zsh/${V}/functions/_pfctl
@comment share/zsh/${V}/functions/_pfctl.orig
share/zsh/${V}/functions/_pfexec
share/zsh/${V}/functions/_php
share/zsh/${V}/functions/_physical_volumes