On 17:57, Thu 10 Dec 09, Pierre-Emmanuel Andr? wrote:
> Hi,
> 
> This diff fixes the completion for tmux and add completion 
> for pfctl.
> 
> Tested on @macppc.

Works on amd64 and i386.
Very nice.

> 
> Comments ?
> 
> Regards,
> 
> -- 
> Pierre-Emmanuel Andr? <pea at raveland.org>
> GPG key: 0x7AE329DC

> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/shells/zsh/Makefile,v
> retrieving revision 1.51
> diff -u -p -r1.51 Makefile
> --- Makefile  13 Nov 2009 12:26:40 -0000      1.51
> +++ Makefile  10 Dec 2009 16:53:43 -0000
> @@ -4,7 +4,7 @@ COMMENT=      Z shell, Bourne shell-compatibl
>  
>  V=           4.3.10
>  DISTNAME=    zsh-$V
> -PKGNAME=     ${DISTNAME}p0
> +PKGNAME=     ${DISTNAME}p1
>  CATEGORIES=  shells
>  
>  MAINTAINER=  Pierre-Emmanuel Andre <[email protected]>
> Index: patches/patch-Completion_BSD_Command__pfctl
> ===================================================================
> RCS file: patches/patch-Completion_BSD_Command__pfctl
> diff -N patches/patch-Completion_BSD_Command__pfctl
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-Completion_BSD_Command__pfctl       10 Dec 2009 16:53:43 
> -0000
> @@ -0,0 +1,100 @@
> +$OpenBSD$
> +--- 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]'
> Index: patches/patch-Completion_Unix_Command__tmux
> ===================================================================
> RCS file: /cvs/ports/shells/zsh/patches/patch-Completion_Unix_Command__tmux,v
> retrieving revision 1.1
> diff -u -p -r1.1 patch-Completion_Unix_Command__tmux
> --- patches/patch-Completion_Unix_Command__tmux       13 Nov 2009 12:26:40 
> -0000      1.1
> +++ patches/patch-Completion_Unix_Command__tmux       10 Dec 2009 16:53:43 
> -0000
> @@ -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 @@
> +--- 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_
>  +    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_
>  +
>  +    # 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_
>  +    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_
>  +    _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_
>  +    [[ -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_
>  +
>  +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_
>  +        '*:: :->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_
>  +    _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_
>  +    [[ -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_
>  +    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_
>  +            '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_
>  +            '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_
>  +        '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_
>  +    _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_
>  +        '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
> Index: pkg/PLIST
> ===================================================================
> RCS file: /cvs/ports/shells/zsh/pkg/PLIST,v
> retrieving revision 1.28
> diff -u -p -r1.28 PLIST
> --- pkg/PLIST 13 Nov 2009 12:26:40 -0000      1.28
> +++ pkg/PLIST 10 Dec 2009 16:53:43 -0000
> @@ -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


-- 

Michiel van Baak
[email protected]
http://michiel.vanbaak.eu
GnuPG key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x71C946BD

"Why is it drug addicts and computer aficionados are both called users?"

Reply via email to