Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to make a function use inbuilt completions of another command?



It turns out that tmux has an inbuilt way of supporting this behaviour.
The -A flag makes new-session behave like attach-session if session-name
already exists.
I have modified the completion script to support this:
--- /usr/share/zsh/functions/Completion/Unix/_tmux      2014-01-06
05:59:47.000000000 -0500
+++ _tmux       2014-07-20 20:50:01.994939784 -0400
@@ -573,12 +573,13 @@
     local -a args
     args=(
         '-d[do not attach new session to current terminal]'
+        '-A[attach to existing session if it already exists]'
         '-n[name the initial window]:window name'
-        '-s[name the session]:session name'
+        '-s[name the session]:session name:__tmux-sessions'
         '-t[specify target session]:sessions:__tmux-sessions'
         '*:: :_command'
     )
-    _arguments ${args}
+    _arguments -s ${args}
 }

 function _tmux-new-window() {



On Tue, Feb 4, 2014 at 1:08 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
wrote:

> On Feb 4,  5:10pm, Frank Terbeck wrote:
> }
> } >     compdef _tmux funcname=sessions
> }
> } I wrote the _tmux completion and indeed don't have a clue about said
> } extension. Where can I take a closer look at it? Which completion should
> } I look at for guidance?
>
> Any of these should be good:
>
>     _pkgtool
>     _git
>     _urpmi
>     _uml
>
> Or just fgrep Completion/**/*(.) for references to '$service' ...
>



-- 
have a nice day
-jck


Messages sorted by: Reverse Date, Date, Thread, Author