diff --git a/completers/tmux_completer/cmd/_tmux b/completers/tmux_completer/cmd/_tmux index 844af58fc0..5b42b405ea 100644 --- a/completers/tmux_completer/cmd/_tmux +++ b/completers/tmux_completer/cmd/_tmux @@ -1896,4 +1896,5 @@ for f in ${(M)${(k)functions}:#_tmux-*} ; do [[ -n ${rev[${f#_tmux-}]} ]] && _tmux_aliases+=( "${rev[${f#_tmux-}]}${desc:+:$desc}" ) done -_tmux "$@" +compquote '' 2>/dev/null && _tmux "$@" +compdef _tmux tmux diff --git a/completers/tmux_completer/cmd/bindKey.go b/completers/tmux_completer/cmd/bindKey.go new file mode 100644 index 0000000000..48b9df98a9 --- /dev/null +++ b/completers/tmux_completer/cmd/bindKey.go @@ -0,0 +1,36 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/bridge" + "github.com/spf13/cobra" +) + +var bindKeyCmd = &cobra.Command{ + Use: "bind-key", + Short: "bind a key to a command", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(bindKeyCmd).Standalone() + + bindKeyCmd.Flags().StringS("N", "N", "", "attach a note to the key") + bindKeyCmd.Flags().StringS("T", "T", "", "specify key table for the binding") + bindKeyCmd.Flags().BoolS("n", "n", false, "make the binding work without the need for the prefix key") + bindKeyCmd.Flags().BoolS("r", "r", false, "the key may repeat") + rootCmd.AddCommand(bindKeyCmd) + + // TODO key table + + carapace.Gen(bindKeyCmd).PositionalCompletion( + carapace.ActionValues(), + ) + + carapace.Gen(bindKeyCmd).PositionalAnyCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + c.Args = c.Args[1:] + return bridge.ActionCarapaceBin("tmux").Invoke(c).ToA() + }), + ) +} diff --git a/completers/tmux_completer/cmd/bindKey_generated.go b/completers/tmux_completer/cmd/bindKey_generated.go deleted file mode 100644 index 5f98b70208..0000000000 --- a/completers/tmux_completer/cmd/bindKey_generated.go +++ /dev/null @@ -1,22 +0,0 @@ -package cmd - -import ( - "github.com/rsteube/carapace" - "github.com/spf13/cobra" -) - -var bindKeyCmd = &cobra.Command{ - Use: "bind-key", - Short: "", - Run: func(cmd *cobra.Command, args []string) {}, -} - -func init() { - carapace.Gen(bindKeyCmd).Standalone() - - bindKeyCmd.Flags().StringS("N", "N", "", "note") - bindKeyCmd.Flags().StringS("T", "T", "", "key-table") - bindKeyCmd.Flags().BoolS("n", "n", false, "TODO description") - bindKeyCmd.Flags().BoolS("r", "r", false, "TODO description") - rootCmd.AddCommand(bindKeyCmd) -} diff --git a/completers/tmux_completer/cmd/root.go b/completers/tmux_completer/cmd/root.go index 5d7e630ba6..aca3dd0b9a 100644 --- a/completers/tmux_completer/cmd/root.go +++ b/completers/tmux_completer/cmd/root.go @@ -41,8 +41,4 @@ func init() { "c": carapace.ActionFiles(), "f": carapace.ActionFiles(), }) - - carapace.Gen(rootCmd).PositionalCompletion( - carapace.ActionFiles(), - ) }