From f764106433aa47d9cbb40b416e1b3390a5984532 Mon Sep 17 00:00:00 2001 From: rsteube Date: Wed, 4 Oct 2023 13:02:01 +0200 Subject: [PATCH] added wezterm --- completers/wezterm_completer/cmd/cli.go | 22 +++++++ .../wezterm_completer/cmd/cli_activatePane.go | 25 +++++++ .../cmd/cli_activatePaneDirection.go | 29 ++++++++ .../wezterm_completer/cmd/cli_activateTab.go | 31 +++++++++ .../cmd/cli_adjustPaneSize.go | 30 +++++++++ .../cmd/cli_getPaneDirection.go | 29 ++++++++ .../wezterm_completer/cmd/cli_getText.go | 28 ++++++++ completers/wezterm_completer/cmd/cli_help.go | 22 +++++++ .../wezterm_completer/cmd/cli_killPane.go | 25 +++++++ completers/wezterm_completer/cmd/cli_list.go | 24 +++++++ .../wezterm_completer/cmd/cli_listClients.go | 24 +++++++ .../cmd/cli_movePaneToNewTab.go | 29 ++++++++ completers/wezterm_completer/cmd/cli_proxy.go | 19 ++++++ .../cmd/cli_renameWorkspace.go | 27 ++++++++ .../wezterm_completer/cmd/cli_sendText.go | 26 ++++++++ .../wezterm_completer/cmd/cli_setTabTitle.go | 27 ++++++++ .../cmd/cli_setWindowTitle.go | 27 ++++++++ completers/wezterm_completer/cmd/cli_spawn.go | 40 +++++++++++ .../wezterm_completer/cmd/cli_splitPane.go | 44 +++++++++++++ completers/wezterm_completer/cmd/connect.go | 29 ++++++++ completers/wezterm_completer/cmd/help.go | 22 +++++++ completers/wezterm_completer/cmd/imgcat.go | 26 ++++++++ completers/wezterm_completer/cmd/lsFonts.go | 23 +++++++ completers/wezterm_completer/cmd/record.go | 25 +++++++ completers/wezterm_completer/cmd/replay.go | 26 ++++++++ completers/wezterm_completer/cmd/root.go | 31 +++++++++ completers/wezterm_completer/cmd/serial.go | 40 +++++++++++ .../cmd/setWorkingDirectory.go | 23 +++++++ .../wezterm_completer/cmd/shellCompletion.go | 24 +++++++ completers/wezterm_completer/cmd/showKeys.go | 21 ++++++ completers/wezterm_completer/cmd/ssh.go | 47 +++++++++++++ completers/wezterm_completer/cmd/start.go | 43 ++++++++++++ completers/wezterm_completer/main.go | 7 ++ pkg/actions/net/baud.go | 24 +++++++ pkg/actions/tools/wezterm/pane.go | 66 +++++++++++++++++++ pkg/actions/tools/wezterm/tab.go | 21 ++++++ pkg/actions/tools/wezterm/window.go | 21 ++++++ 37 files changed, 1047 insertions(+) create mode 100644 completers/wezterm_completer/cmd/cli.go create mode 100644 completers/wezterm_completer/cmd/cli_activatePane.go create mode 100644 completers/wezterm_completer/cmd/cli_activatePaneDirection.go create mode 100644 completers/wezterm_completer/cmd/cli_activateTab.go create mode 100644 completers/wezterm_completer/cmd/cli_adjustPaneSize.go create mode 100644 completers/wezterm_completer/cmd/cli_getPaneDirection.go create mode 100644 completers/wezterm_completer/cmd/cli_getText.go create mode 100644 completers/wezterm_completer/cmd/cli_help.go create mode 100644 completers/wezterm_completer/cmd/cli_killPane.go create mode 100644 completers/wezterm_completer/cmd/cli_list.go create mode 100644 completers/wezterm_completer/cmd/cli_listClients.go create mode 100644 completers/wezterm_completer/cmd/cli_movePaneToNewTab.go create mode 100644 completers/wezterm_completer/cmd/cli_proxy.go create mode 100644 completers/wezterm_completer/cmd/cli_renameWorkspace.go create mode 100644 completers/wezterm_completer/cmd/cli_sendText.go create mode 100644 completers/wezterm_completer/cmd/cli_setTabTitle.go create mode 100644 completers/wezterm_completer/cmd/cli_setWindowTitle.go create mode 100644 completers/wezterm_completer/cmd/cli_spawn.go create mode 100644 completers/wezterm_completer/cmd/cli_splitPane.go create mode 100644 completers/wezterm_completer/cmd/connect.go create mode 100644 completers/wezterm_completer/cmd/help.go create mode 100644 completers/wezterm_completer/cmd/imgcat.go create mode 100644 completers/wezterm_completer/cmd/lsFonts.go create mode 100644 completers/wezterm_completer/cmd/record.go create mode 100644 completers/wezterm_completer/cmd/replay.go create mode 100644 completers/wezterm_completer/cmd/root.go create mode 100644 completers/wezterm_completer/cmd/serial.go create mode 100644 completers/wezterm_completer/cmd/setWorkingDirectory.go create mode 100644 completers/wezterm_completer/cmd/shellCompletion.go create mode 100644 completers/wezterm_completer/cmd/showKeys.go create mode 100644 completers/wezterm_completer/cmd/ssh.go create mode 100644 completers/wezterm_completer/cmd/start.go create mode 100644 completers/wezterm_completer/main.go create mode 100644 pkg/actions/net/baud.go create mode 100644 pkg/actions/tools/wezterm/pane.go create mode 100644 pkg/actions/tools/wezterm/tab.go create mode 100644 pkg/actions/tools/wezterm/window.go diff --git a/completers/wezterm_completer/cmd/cli.go b/completers/wezterm_completer/cmd/cli.go new file mode 100644 index 0000000000..06c3f80c55 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var cliCmd = &cobra.Command{ + Use: "cli [OPTIONS] ", + Short: "Interact with experimental mux server", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cliCmd).Standalone() + + cliCmd.Flags().String("class", "", "Class of the gui instance") + cliCmd.Flags().BoolP("help", "h", false, "Print help") + cliCmd.Flags().Bool("no-auto-start", false, "Don't automatically start the server") + cliCmd.Flags().Bool("prefer-mux", false, "Prefer connecting to a background mux server") + rootCmd.AddCommand(cliCmd) +} diff --git a/completers/wezterm_completer/cmd/cli_activatePane.go b/completers/wezterm_completer/cmd/cli_activatePane.go new file mode 100644 index 0000000000..43ca32544a --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_activatePane.go @@ -0,0 +1,25 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_activatePaneCmd = &cobra.Command{ + Use: "activate-pane [OPTIONS]", + Short: "Activate (focus) a pane", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_activatePaneCmd).Standalone() + + cli_activatePaneCmd.Flags().BoolP("help", "h", false, "Print help") + cli_activatePaneCmd.Flags().String("pane-id", "", "Specify the target pane") + cliCmd.AddCommand(cli_activatePaneCmd) + + carapace.Gen(cli_activatePaneCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + }) +} diff --git a/completers/wezterm_completer/cmd/cli_activatePaneDirection.go b/completers/wezterm_completer/cmd/cli_activatePaneDirection.go new file mode 100644 index 0000000000..e3105eff30 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_activatePaneDirection.go @@ -0,0 +1,29 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_activatePaneDirectionCmd = &cobra.Command{ + Use: "activate-pane-direction [OPTIONS] ", + Short: "Activate an adjacent pane in the specified direction", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_activatePaneDirectionCmd).Standalone() + + cli_activatePaneDirectionCmd.Flags().BoolP("help", "h", false, "Print help") + cli_activatePaneDirectionCmd.Flags().String("pane-id", "", "Specify the current pane") + cliCmd.AddCommand(cli_activatePaneDirectionCmd) + + carapace.Gen(cli_activatePaneDirectionCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + }) + + carapace.Gen(cli_activatePaneDirectionCmd).PositionalCompletion( + wezterm.ActionPaneDirections(), + ) +} diff --git a/completers/wezterm_completer/cmd/cli_activateTab.go b/completers/wezterm_completer/cmd/cli_activateTab.go new file mode 100644 index 0000000000..befbc94f2f --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_activateTab.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_activateTabCmd = &cobra.Command{ + Use: "activate-tab [OPTIONS]", + Short: "Activate a tab", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_activateTabCmd).Standalone() + + cli_activateTabCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')") + cli_activateTabCmd.Flags().Bool("no-wrap", false, "Prevents wrapping around") + cli_activateTabCmd.Flags().String("pane-id", "", "Specify the current pane") + cli_activateTabCmd.Flags().String("tab-id", "", "Specify the target tab by its id") + cli_activateTabCmd.Flags().String("tab-index", "", "Specify the target tab by its index") + cli_activateTabCmd.Flags().String("tab-relative", "", "Specify the target tab by its relative offset") + cliCmd.AddCommand(cli_activateTabCmd) + + carapace.Gen(cli_activateTabCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + "tab-id": wezterm.ActionTabs(), + // TODO more flags + }) +} diff --git a/completers/wezterm_completer/cmd/cli_adjustPaneSize.go b/completers/wezterm_completer/cmd/cli_adjustPaneSize.go new file mode 100644 index 0000000000..8c050d5990 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_adjustPaneSize.go @@ -0,0 +1,30 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_adjustPaneSizeCmd = &cobra.Command{ + Use: "adjust-pane-size [OPTIONS] ", + Short: "Adjust the size of a pane directionally", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_adjustPaneSizeCmd).Standalone() + + cli_adjustPaneSizeCmd.Flags().String("amount", "", "Specify the number of cells to resize by, defaults to 1") + cli_adjustPaneSizeCmd.Flags().BoolP("help", "h", false, "Print help") + cli_adjustPaneSizeCmd.Flags().String("pane-id", "", "Specify the target pane") + cliCmd.AddCommand(cli_adjustPaneSizeCmd) + + carapace.Gen(cli_adjustPaneSizeCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + }) + + carapace.Gen(cli_adjustPaneSizeCmd).PositionalCompletion( + wezterm.ActionPaneDirections(), + ) +} diff --git a/completers/wezterm_completer/cmd/cli_getPaneDirection.go b/completers/wezterm_completer/cmd/cli_getPaneDirection.go new file mode 100644 index 0000000000..3a4513c645 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_getPaneDirection.go @@ -0,0 +1,29 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_getPaneDirectionCmd = &cobra.Command{ + Use: "get-pane-direction [OPTIONS] ", + Short: "Determine the adjacent pane in the specified direction", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_getPaneDirectionCmd).Standalone() + + cli_getPaneDirectionCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')") + cli_getPaneDirectionCmd.Flags().String("pane-id", "", "Specify the current pane") + cliCmd.AddCommand(cli_getPaneDirectionCmd) + + carapace.Gen(cli_getPaneDirectionCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + }) + + carapace.Gen(cli_getPaneDirectionCmd).PositionalCompletion( + wezterm.ActionPaneDirections(), + ) +} diff --git a/completers/wezterm_completer/cmd/cli_getText.go b/completers/wezterm_completer/cmd/cli_getText.go new file mode 100644 index 0000000000..84db76788a --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_getText.go @@ -0,0 +1,28 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_getTextCmd = &cobra.Command{ + Use: "get-text [OPTIONS]", + Short: "Retrieves the textual content of a pane and output it to stdout", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_getTextCmd).Standalone() + + cli_getTextCmd.Flags().String("end-line", "", "The ending line number") + cli_getTextCmd.Flags().Bool("escapes", false, "Include escape sequences that color and style the text") + cli_getTextCmd.Flags().BoolP("help", "h", false, "Print help") + cli_getTextCmd.Flags().String("pane-id", "", "Specify the target pane") + cli_getTextCmd.Flags().String("start-line", "", "The starting line number") + cliCmd.AddCommand(cli_getTextCmd) + + carapace.Gen(cli_getTextCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + }) +} diff --git a/completers/wezterm_completer/cmd/cli_help.go b/completers/wezterm_completer/cmd/cli_help.go new file mode 100644 index 0000000000..cc9fa27376 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_help.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var cli_helpCmd = &cobra.Command{ + Use: "help [COMMAND]...", + Short: "Print this message or the help of the given subcommand(s)", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_helpCmd).Standalone() + + cliCmd.AddCommand(cli_helpCmd) + + carapace.Gen(cli_helpCmd).PositionalAnyCompletion( + carapace.ActionCommands(cli_helpCmd), + ) +} diff --git a/completers/wezterm_completer/cmd/cli_killPane.go b/completers/wezterm_completer/cmd/cli_killPane.go new file mode 100644 index 0000000000..17ff406386 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_killPane.go @@ -0,0 +1,25 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_killPaneCmd = &cobra.Command{ + Use: "kill-pane [OPTIONS]", + Short: "Kill a pane", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_killPaneCmd).Standalone() + + cli_killPaneCmd.Flags().BoolP("help", "h", false, "Print help") + cli_killPaneCmd.Flags().String("pane-id", "", "Specify the target pane") + cliCmd.AddCommand(cli_killPaneCmd) + + carapace.Gen(cli_killPaneCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + }) +} diff --git a/completers/wezterm_completer/cmd/cli_list.go b/completers/wezterm_completer/cmd/cli_list.go new file mode 100644 index 0000000000..8b6cb45bef --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_list.go @@ -0,0 +1,24 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var cli_listCmd = &cobra.Command{ + Use: "list [OPTIONS]", + Short: "list windows, tabs and panes", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_listCmd).Standalone() + + cli_listCmd.Flags().String("format", "", "Controls the output format") + cli_listCmd.Flags().BoolP("help", "h", false, "Print help") + cliCmd.AddCommand(cli_listCmd) + + carapace.Gen(cli_listCmd).FlagCompletion(carapace.ActionMap{ + "format": carapace.ActionValues("table", "json"), + }) +} diff --git a/completers/wezterm_completer/cmd/cli_listClients.go b/completers/wezterm_completer/cmd/cli_listClients.go new file mode 100644 index 0000000000..4e83dac1e5 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_listClients.go @@ -0,0 +1,24 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var cli_listClientsCmd = &cobra.Command{ + Use: "list-clients [OPTIONS]", + Short: "list clients", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_listClientsCmd).Standalone() + + cli_listClientsCmd.Flags().String("format", "", "Controls the output format") + cli_listClientsCmd.Flags().BoolP("help", "h", false, "Print help") + cliCmd.AddCommand(cli_listClientsCmd) + + carapace.Gen(cli_listClientsCmd).FlagCompletion(carapace.ActionMap{ + "format": carapace.ActionValues("table", "json"), + }) +} diff --git a/completers/wezterm_completer/cmd/cli_movePaneToNewTab.go b/completers/wezterm_completer/cmd/cli_movePaneToNewTab.go new file mode 100644 index 0000000000..6bdc127897 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_movePaneToNewTab.go @@ -0,0 +1,29 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_movePaneToNewTabCmd = &cobra.Command{ + Use: "move-pane-to-new-tab [OPTIONS]", + Short: "Move a pane into a new tab", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_movePaneToNewTabCmd).Standalone() + + cli_movePaneToNewTabCmd.Flags().BoolP("help", "h", false, "Print help") + cli_movePaneToNewTabCmd.Flags().Bool("new-window", false, "Create tab in a new window") + cli_movePaneToNewTabCmd.Flags().String("pane-id", "", "Specify the pane that should be moved") + cli_movePaneToNewTabCmd.Flags().String("window-id", "", "Specify the window into which the new tab will be created") + cli_movePaneToNewTabCmd.Flags().String("workspace", "", "Override the default workspace name with the provided name") + cliCmd.AddCommand(cli_movePaneToNewTabCmd) + + carapace.Gen(cli_movePaneToNewTabCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + "window-id": wezterm.ActionWindows(), + }) +} diff --git a/completers/wezterm_completer/cmd/cli_proxy.go b/completers/wezterm_completer/cmd/cli_proxy.go new file mode 100644 index 0000000000..a30043c1aa --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_proxy.go @@ -0,0 +1,19 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var cli_proxyCmd = &cobra.Command{ + Use: "proxy", + Short: "start rpc proxy pipe", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_proxyCmd).Standalone() + + cli_proxyCmd.Flags().BoolP("help", "h", false, "Print help") + cliCmd.AddCommand(cli_proxyCmd) +} diff --git a/completers/wezterm_completer/cmd/cli_renameWorkspace.go b/completers/wezterm_completer/cmd/cli_renameWorkspace.go new file mode 100644 index 0000000000..f5d3a81886 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_renameWorkspace.go @@ -0,0 +1,27 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_renameWorkspaceCmd = &cobra.Command{ + Use: "rename-workspace [OPTIONS] ", + Short: "Rename a workspace", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_renameWorkspaceCmd).Standalone() + + cli_renameWorkspaceCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')") + cli_renameWorkspaceCmd.Flags().String("pane-id", "", "Specify the current pane") + cli_renameWorkspaceCmd.Flags().String("workspace", "", "Specify the workspace to rename") + cliCmd.AddCommand(cli_renameWorkspaceCmd) + + carapace.Gen(cli_renameWorkspaceCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + // TODO workspace + }) +} diff --git a/completers/wezterm_completer/cmd/cli_sendText.go b/completers/wezterm_completer/cmd/cli_sendText.go new file mode 100644 index 0000000000..34c9c6fabc --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_sendText.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_sendTextCmd = &cobra.Command{ + Use: "send-text [OPTIONS] [TEXT]", + Short: "Send text to a pane as though it were pasted", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_sendTextCmd).Standalone() + + cli_sendTextCmd.Flags().BoolP("help", "h", false, "Print help") + cli_sendTextCmd.Flags().Bool("no-paste", false, "Send the text directly, rather than as a bracketed paste") + cli_sendTextCmd.Flags().String("pane-id", "", "Specify the target pane") + cliCmd.AddCommand(cli_sendTextCmd) + + carapace.Gen(cli_sendTextCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + }) +} diff --git a/completers/wezterm_completer/cmd/cli_setTabTitle.go b/completers/wezterm_completer/cmd/cli_setTabTitle.go new file mode 100644 index 0000000000..29b4d7f9c8 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_setTabTitle.go @@ -0,0 +1,27 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_setTabTitleCmd = &cobra.Command{ + Use: "set-tab-title [OPTIONS] ", + Short: "Change the title of a tab", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_setTabTitleCmd).Standalone() + + cli_setTabTitleCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')") + cli_setTabTitleCmd.Flags().String("pane-id", "", "Specify the current pane") + cli_setTabTitleCmd.Flags().String("tab-id", "", "Specify the target tab by its id") + cliCmd.AddCommand(cli_setTabTitleCmd) + + carapace.Gen(cli_setTabTitleCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + "tab-id": wezterm.ActionTabs(), + }) +} diff --git a/completers/wezterm_completer/cmd/cli_setWindowTitle.go b/completers/wezterm_completer/cmd/cli_setWindowTitle.go new file mode 100644 index 0000000000..98f7ad1b7c --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_setWindowTitle.go @@ -0,0 +1,27 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/spf13/cobra" +) + +var cli_setWindowTitleCmd = &cobra.Command{ + Use: "set-window-title [OPTIONS] <TITLE>", + Short: "Change the title of a window", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_setWindowTitleCmd).Standalone() + + cli_setWindowTitleCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')") + cli_setWindowTitleCmd.Flags().String("pane-id", "", "Specify the current pane") + cli_setWindowTitleCmd.Flags().String("window-id", "", "Specify the target window by its id") + cliCmd.AddCommand(cli_setWindowTitleCmd) + + carapace.Gen(cli_setWindowTitleCmd).FlagCompletion(carapace.ActionMap{ + "pane-id": wezterm.ActionPanes(), + "window-id": wezterm.ActionWindows(), + }) +} diff --git a/completers/wezterm_completer/cmd/cli_spawn.go b/completers/wezterm_completer/cmd/cli_spawn.go new file mode 100644 index 0000000000..cb4c351cb0 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_spawn.go @@ -0,0 +1,40 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/rsteube/carapace-bridge/pkg/actions/bridge" + "github.com/rsteube/carapace/pkg/traverse" + "github.com/spf13/cobra" +) + +var cli_spawnCmd = &cobra.Command{ + Use: "spawn [OPTIONS] [PROG]...", + Short: "Spawn a command into a new window or tab", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_spawnCmd).Standalone() + cli_spawnCmd.Flags().SetInterspersed(false) + + cli_spawnCmd.Flags().String("cwd", "", "Specify the current working directory for the initially spawned program") + cli_spawnCmd.Flags().String("domain-name", "", "") + cli_spawnCmd.Flags().BoolP("help", "h", false, "Print help") + cli_spawnCmd.Flags().Bool("new-window", false, "Spawn into a new window, rather than a new tab") + cli_spawnCmd.Flags().String("pane-id", "", "Specify the current pane") + cli_spawnCmd.Flags().String("window-id", "", "Specify the window into which to spawn a tab") + cli_spawnCmd.Flags().String("workspace", "", "Override the default workspace name with the provided name") + cliCmd.AddCommand(cli_spawnCmd) + + // TODO flag completion + carapace.Gen(cli_spawnCmd).FlagCompletion(carapace.ActionMap{ + "cwd": carapace.ActionDirectories(), + "pane-id": wezterm.ActionPanes(), + "window-id": wezterm.ActionWindows(), + }) + + carapace.Gen(cli_spawnCmd).PositionalAnyCompletion( + bridge.ActionCarapaceBin().ChdirF(traverse.Flag(cli_spawnCmd.Flag("cwd"))), + ) +} diff --git a/completers/wezterm_completer/cmd/cli_splitPane.go b/completers/wezterm_completer/cmd/cli_splitPane.go new file mode 100644 index 0000000000..3149b11a15 --- /dev/null +++ b/completers/wezterm_completer/cmd/cli_splitPane.go @@ -0,0 +1,44 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/wezterm" + "github.com/rsteube/carapace-bridge/pkg/actions/bridge" + "github.com/rsteube/carapace/pkg/traverse" + "github.com/spf13/cobra" +) + +var cli_splitPaneCmd = &cobra.Command{ + Use: "split-pane [OPTIONS] [PROG]...", + Short: "Move a pane into a new tab", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cli_splitPaneCmd).Standalone() + cli_splitPaneCmd.Flags().SetInterspersed(false) + + cli_splitPaneCmd.Flags().Bool("bottom", false, "Split vertically, with the new pane on the bottom") + cli_splitPaneCmd.Flags().String("cells", "", "The number of cells that the new split should have") + cli_splitPaneCmd.Flags().String("cwd", "", "Specify the current working directory for the initially spawned program") + cli_splitPaneCmd.Flags().BoolP("help", "h", false, "Print help") + cli_splitPaneCmd.Flags().Bool("horizontal", false, "Equivalent to `--right`") + cli_splitPaneCmd.Flags().Bool("left", false, "Split horizontally, with the new pane on the left") + cli_splitPaneCmd.Flags().String("move-pane-id", "", "Move the specified pane into the newly created split") + cli_splitPaneCmd.Flags().String("pane-id", "", "Specify the pane that should be split") + cli_splitPaneCmd.Flags().String("percent", "", "Specify the number of cells that the new split should have") + cli_splitPaneCmd.Flags().Bool("right", false, "Split horizontally, with the new pane on the right") + cli_splitPaneCmd.Flags().Bool("top", false, "Split vertically, with the new pane on the top") + cli_splitPaneCmd.Flags().Bool("top-level", false, "Rather than splitting the active pane, split the entire window") + cliCmd.AddCommand(cli_splitPaneCmd) + + carapace.Gen(cli_splitPaneCmd).FlagCompletion(carapace.ActionMap{ + "cwd": carapace.ActionDirectories(), + "move-pane-id": wezterm.ActionPanes(), + "pane-id": wezterm.ActionPanes(), + }) + + carapace.Gen(cli_splitPaneCmd).PositionalAnyCompletion( + bridge.ActionCarapaceBin().ChdirF(traverse.Flag(cli_splitPaneCmd.Flag("cwd"))), + ) +} diff --git a/completers/wezterm_completer/cmd/connect.go b/completers/wezterm_completer/cmd/connect.go new file mode 100644 index 0000000000..96e1d42ae2 --- /dev/null +++ b/completers/wezterm_completer/cmd/connect.go @@ -0,0 +1,29 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bridge/pkg/actions/bridge" + "github.com/spf13/cobra" +) + +var connectCmd = &cobra.Command{ + Use: "connect [OPTIONS] <DOMAIN_NAME> [PROG]...", + Short: "Connect to wezterm multiplexer", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(connectCmd).Standalone() + connectCmd.Flags().SetInterspersed(false) + + connectCmd.Flags().String("class", "", "Override the default windowing system class") + connectCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')") + connectCmd.Flags().String("position", "", "Override the position for the initial window launched by this process") + connectCmd.Flags().String("workspace", "", "Override the default workspace with the provided name") + rootCmd.AddCommand(connectCmd) + + carapace.Gen(connectCmd).PositionalCompletion( + carapace.ActionValues(), // TODO domain + bridge.ActionCarapaceBin().Shift(1), + ) +} diff --git a/completers/wezterm_completer/cmd/help.go b/completers/wezterm_completer/cmd/help.go new file mode 100644 index 0000000000..f9c58804fe --- /dev/null +++ b/completers/wezterm_completer/cmd/help.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var helpCmd = &cobra.Command{ + Use: "help", + Short: "Print this message or the help of the given subcommand(s)", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(helpCmd).Standalone() + + rootCmd.AddCommand(helpCmd) + + carapace.Gen(helpCmd).PositionalAnyCompletion( + carapace.ActionCommands(rootCmd), + ) +} diff --git a/completers/wezterm_completer/cmd/imgcat.go b/completers/wezterm_completer/cmd/imgcat.go new file mode 100644 index 0000000000..99f8f87a62 --- /dev/null +++ b/completers/wezterm_completer/cmd/imgcat.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var imgcatCmd = &cobra.Command{ + Use: "imgcat [OPTIONS] [FILE", + Short: "Output an image to the terminal", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(imgcatCmd).Standalone() + + imgcatCmd.Flags().String("height", "", "Specify the display height") + imgcatCmd.Flags().BoolP("help", "h", false, "Print help") + imgcatCmd.Flags().Bool("no-preserve-aspect-ratio", false, "Do not respect the aspect ratio") + imgcatCmd.Flags().String("width", "", "Specify the display width") + rootCmd.AddCommand(imgcatCmd) + + carapace.Gen(imgcatCmd).PositionalCompletion( + carapace.ActionFiles(), + ) +} diff --git a/completers/wezterm_completer/cmd/lsFonts.go b/completers/wezterm_completer/cmd/lsFonts.go new file mode 100644 index 0000000000..17d85ef461 --- /dev/null +++ b/completers/wezterm_completer/cmd/lsFonts.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var lsFontsCmd = &cobra.Command{ + Use: "ls-fonts [OPTIONS]", + Short: "Display information about fonts", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(lsFontsCmd).Standalone() + + lsFontsCmd.Flags().String("codepoints", "", "Explain which fonts are used to render the specified unicode code point sequence") + lsFontsCmd.Flags().BoolP("help", "h", false, "Print help") + lsFontsCmd.Flags().Bool("list-system", false, "Whether to list all fonts available to the system") + lsFontsCmd.Flags().Bool("rasterize-ascii", false, "Show rasterized glyphs for the text in --text or --codepoints using ascii blocks") + lsFontsCmd.Flags().String("text", "", "Explain which fonts are used to render the supplied text string") + rootCmd.AddCommand(lsFontsCmd) +} diff --git a/completers/wezterm_completer/cmd/record.go b/completers/wezterm_completer/cmd/record.go new file mode 100644 index 0000000000..b1092cdab6 --- /dev/null +++ b/completers/wezterm_completer/cmd/record.go @@ -0,0 +1,25 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bridge/pkg/actions/bridge" + "github.com/spf13/cobra" +) + +var recordCmd = &cobra.Command{ + Use: "record [PROG]...", + Short: "Record a terminal session as an asciicast", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(recordCmd).Standalone() + recordCmd.Flags().SetInterspersed(false) + + recordCmd.Flags().BoolP("help", "h", false, "Print help") + rootCmd.AddCommand(recordCmd) + + carapace.Gen(recordCmd).PositionalAnyCompletion( + bridge.ActionCarapaceBin(), + ) +} diff --git a/completers/wezterm_completer/cmd/replay.go b/completers/wezterm_completer/cmd/replay.go new file mode 100644 index 0000000000..f5790ee9e0 --- /dev/null +++ b/completers/wezterm_completer/cmd/replay.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var replayCmd = &cobra.Command{ + Use: "replay [OPTIONS] <CAST_FILE>", + Short: "Replay an asciicast terminal session", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(replayCmd).Standalone() + + replayCmd.Flags().Bool("cat", false, "Just emit raw escape sequences all at once, with no timing information") + replayCmd.Flags().Bool("explain", false, "Explain what is being sent/received") + replayCmd.Flags().Bool("explain-only", false, "Don't replay, just show the explanation") + replayCmd.Flags().BoolP("help", "h", false, "Print help") + rootCmd.AddCommand(replayCmd) + + carapace.Gen(replayCmd).PositionalCompletion( + carapace.ActionFiles(".cast"), + ) +} diff --git a/completers/wezterm_completer/cmd/root.go b/completers/wezterm_completer/cmd/root.go new file mode 100644 index 0000000000..e4fdd80c34 --- /dev/null +++ b/completers/wezterm_completer/cmd/root.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "wezterm [OPTIONS] [COMMAND]", + Short: "Wez's Terminal Emulator", + Long: "http://github.com/wez/wezterm", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func Execute() error { + return rootCmd.Execute() +} +func init() { + carapace.Gen(rootCmd).Standalone() + + rootCmd.Flags().String("config", "", "Override specific configuration values") + rootCmd.Flags().String("config-file", "", "Specify the configuration file to use, overrides the normal") + rootCmd.Flags().BoolP("help", "h", false, "Print help") + rootCmd.Flags().BoolP("skip-config", "n", false, "Skip loading wezterm.lua") + rootCmd.Flags().BoolP("version", "V", false, "Print version") + + carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ + // TODO config: https://wezfurlong.org/wezterm/config/lua/config/index.html + "config-file": carapace.ActionFiles(), + }) +} diff --git a/completers/wezterm_completer/cmd/serial.go b/completers/wezterm_completer/cmd/serial.go new file mode 100644 index 0000000000..302298e7a0 --- /dev/null +++ b/completers/wezterm_completer/cmd/serial.go @@ -0,0 +1,40 @@ +package cmd + +import ( + "runtime" + + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/net" + "github.com/spf13/cobra" +) + +var serialCmd = &cobra.Command{ + Use: "serial [OPTIONS] <PORT>", + Short: "Open a serial port", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(serialCmd).Standalone() + + serialCmd.Flags().String("baud", "", "Set the baud rate") + serialCmd.Flags().String("class", "", "Override the default windowing system class") + serialCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')") + serialCmd.Flags().String("position", "", "Override the position for the initial window launched by this process") + rootCmd.AddCommand(serialCmd) + + carapace.Gen(serialCmd).FlagCompletion(carapace.ActionMap{ + "baud": net.ActionBaudRates(), + }) + + carapace.Gen(serialCmd).PositionalCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + switch runtime.GOOS { + case "windows": + return carapace.ActionValues() // TODO COM0... + default: + return carapace.ActionFiles() // TODO /dev/tty... + } + }), + ) +} diff --git a/completers/wezterm_completer/cmd/setWorkingDirectory.go b/completers/wezterm_completer/cmd/setWorkingDirectory.go new file mode 100644 index 0000000000..0a78e867ae --- /dev/null +++ b/completers/wezterm_completer/cmd/setWorkingDirectory.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var setWorkingDirectoryCmd = &cobra.Command{ + Use: "set-working-directory [CWD] [HOST]", + Short: "Advise the terminal of the current working directory by emitting an OSC 7 escape sequence", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(setWorkingDirectoryCmd).Standalone() + + setWorkingDirectoryCmd.Flags().BoolP("help", "h", false, "Print help") + rootCmd.AddCommand(setWorkingDirectoryCmd) + + carapace.Gen(setWorkingDirectoryCmd).PositionalCompletion( + carapace.ActionDirectories(), + ) +} diff --git a/completers/wezterm_completer/cmd/shellCompletion.go b/completers/wezterm_completer/cmd/shellCompletion.go new file mode 100644 index 0000000000..4f6a9f5a97 --- /dev/null +++ b/completers/wezterm_completer/cmd/shellCompletion.go @@ -0,0 +1,24 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var shellCompletionCmd = &cobra.Command{ + Use: "shell-completion --shell <SHELL>", + Short: "Generate shell completion information", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(shellCompletionCmd).Standalone() + + shellCompletionCmd.Flags().BoolP("help", "h", false, "Print help") + shellCompletionCmd.Flags().String("shell", "", "Which shell to generate for") + rootCmd.AddCommand(shellCompletionCmd) + + carapace.Gen(shellCompletionCmd).FlagCompletion(carapace.ActionMap{ + "shell": carapace.ActionValues("bash", "elvish", "fish", "power-shell", "zsh", "fig"), + }) +} diff --git a/completers/wezterm_completer/cmd/showKeys.go b/completers/wezterm_completer/cmd/showKeys.go new file mode 100644 index 0000000000..c0cdb398d1 --- /dev/null +++ b/completers/wezterm_completer/cmd/showKeys.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var showKeysCmd = &cobra.Command{ + Use: "show-keys [OPTIONS]", + Short: "Show key assignments", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(showKeysCmd).Standalone() + + showKeysCmd.Flags().BoolP("help", "h", false, "Print help") + showKeysCmd.Flags().String("key-table", "", "In lua mode, show only the named key table") + showKeysCmd.Flags().Bool("lua", false, "Show the keys as lua config statements") + rootCmd.AddCommand(showKeysCmd) +} diff --git a/completers/wezterm_completer/cmd/ssh.go b/completers/wezterm_completer/cmd/ssh.go new file mode 100644 index 0000000000..7e4b8d0e85 --- /dev/null +++ b/completers/wezterm_completer/cmd/ssh.go @@ -0,0 +1,47 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/net" + "github.com/rsteube/carapace-bin/pkg/actions/os" + "github.com/spf13/cobra" +) + +var sshCmd = &cobra.Command{ + Use: "ssh [OPTIONS] <USER_AT_HOST_AND_PORT> [PROG]...", + Short: "Establish an ssh session", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(sshCmd).Standalone() + + sshCmd.Flags().BoolS("v", "v", false, "Enable verbose ssh protocol tracing") + sshCmd.Flags().String("class", "", "Override the default windowing system class") + sshCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')") + sshCmd.Flags().String("position", "", "Override the position for the initial window launched by this process") + sshCmd.Flags().StringP("ssh-option", "o", "", "Override specific SSH configuration options") + rootCmd.AddCommand(sshCmd) + + carapace.Gen(sshCmd).PositionalCompletion( + carapace.ActionMultiPartsN("@", 2, func(cAt carapace.Context) carapace.Action { + return carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { + switch len(c.Parts) { + case 0: + switch len(cAt.Parts) { + case 0: + return carapace.Batch( + os.ActionUsers().Suffix("@"), + net.ActionHosts(), + ).ToA() + + default: + return net.ActionHosts() + } + default: + return net.ActionKnownPorts() + } + }) + }), + ) +} diff --git a/completers/wezterm_completer/cmd/start.go b/completers/wezterm_completer/cmd/start.go new file mode 100644 index 0000000000..f80f7c44ed --- /dev/null +++ b/completers/wezterm_completer/cmd/start.go @@ -0,0 +1,43 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bridge/pkg/actions/bridge" + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +var startCmd = &cobra.Command{ + Use: "start [OPTIONS] [PROG]...", + Short: "Start the GUI, optionally running an alternative program", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(startCmd).Standalone() + startCmd.Flags().SetInterspersed(false) + + startCmd.Flags().Bool("always-new-process", false, "Do not try to ask an existing wezterm GUI instance to start the command") + startCmd.Flags().Bool("attach", false, "Attach to already running pane of domain") + startCmd.Flags().String("class", "", "Override the default windowing system class") + startCmd.Flags().String("cwd", "", "Specify the current working directory for the initially spawned program") + startCmd.Flags().String("domain", "", "Name of the multiplexer domain section from the configuration to which you'd like to connect") + startCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')") + startCmd.Flags().Bool("no-auto-connect", false, "Do not connect to domains marked as connect_automatically") + startCmd.Flags().String("position", "", "Override the position for the initial window launched by this process") + startCmd.Flags().String("workspace", "", "Override the default workspace with the provided name") + rootCmd.AddCommand(startCmd) + + carapace.Gen(startCmd).FlagCompletion(carapace.ActionMap{ + "cwd": carapace.ActionDirectories(), + // TODO domain + }) + + carapace.Gen(startCmd).PositionalAnyCompletion( + bridge.ActionCarapaceBin(), + ) + + carapace.Gen(startCmd).PreInvoke(func(cmd *cobra.Command, flag *pflag.Flag, action carapace.Action) carapace.Action { + return action.Chdir(cmd.Flag("cwd").Value.String()) + }) +} diff --git a/completers/wezterm_completer/main.go b/completers/wezterm_completer/main.go new file mode 100644 index 0000000000..1c337c683a --- /dev/null +++ b/completers/wezterm_completer/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/rsteube/carapace-bin/completers/wezterm_completer/cmd" + +func main() { + cmd.Execute() +} diff --git a/pkg/actions/net/baud.go b/pkg/actions/net/baud.go new file mode 100644 index 0000000000..43b01be4c7 --- /dev/null +++ b/pkg/actions/net/baud.go @@ -0,0 +1,24 @@ +package net + +import "github.com/rsteube/carapace" + +// ActionBaudRates completes baud rates +// +// 75 +// 300 +func ActionBaudRates() carapace.Action { + return carapace.ActionValues( + "75", + "300", + "1200", + "2400", + "4800", + "9600", + "14400", + "19200", + "28800", + "38400", + "57600", + "115200", + ) +} diff --git a/pkg/actions/tools/wezterm/pane.go b/pkg/actions/tools/wezterm/pane.go new file mode 100644 index 0000000000..c2e3fc39ce --- /dev/null +++ b/pkg/actions/tools/wezterm/pane.go @@ -0,0 +1,66 @@ +package wezterm + +import ( + "encoding/json" + "strconv" + + "github.com/rsteube/carapace" +) + +type pane struct { + WindowID int `json:"window_id"` + TabID int `json:"tab_id"` + PaneID int `json:"pane_id"` + Workspace string `json:"workspace"` + Size struct { + Rows int `json:"rows"` + Cols int `json:"cols"` + PixelWidth int `json:"pixel_width"` + PixelHeight int `json:"pixel_height"` + Dpi int `json:"dpi"` + } `json:"size"` + Title string `json:"title"` + Cwd string `json:"cwd"` + CursorX int `json:"cursor_x"` + CursorY int `json:"cursor_y"` + CursorShape string `json:"cursor_shape"` + CursorVisibility string `json:"cursor_visibility"` + LeftCol int `json:"left_col"` + TopRow int `json:"top_row"` + TabTitle string `json:"tab_title"` + WindowTitle string `json:"window_title"` + IsActive bool `json:"is_active"` + IsZoomed bool `json:"is_zoomed"` + TtyName string `json:"tty_name"` +} + +func actionPanes(f func(panes []pane) carapace.Action) carapace.Action { + return carapace.ActionExecCommand("wezterm", "cli", "list", "--format", "json")(func(output []byte) carapace.Action { + var panes []pane + if err := json.Unmarshal(output, &panes); err != nil { + return carapace.ActionMessage(err.Error()) + } + return f(panes) + }) +} + +// ActionPanes completes panes +// 0 (zsh) +// 1 (fish) +func ActionPanes() carapace.Action { + return actionPanes(func(panes []pane) carapace.Action { + vals := make([]string, 0) + for _, p := range panes { + vals = append(vals, strconv.Itoa(p.PaneID), p.Title) + } + return carapace.ActionValuesDescribed(vals...) + }) +} + +// ActionPaneDirections completes pane directions +// +// Up +// Down +func ActionPaneDirections() carapace.Action { + return carapace.ActionValues("Up", "Down", "Left", "Right", "Next", "Prev") +} diff --git a/pkg/actions/tools/wezterm/tab.go b/pkg/actions/tools/wezterm/tab.go new file mode 100644 index 0000000000..15deee5a47 --- /dev/null +++ b/pkg/actions/tools/wezterm/tab.go @@ -0,0 +1,21 @@ +package wezterm + +import ( + "strconv" + + "github.com/rsteube/carapace" +) + +// ActionTabs completes tabs +// +// 0 +// 1 +func ActionTabs() carapace.Action { + return actionPanes(func(panes []pane) carapace.Action { + vals := make([]string, 0) + for _, p := range panes { + vals = append(vals, strconv.Itoa(p.TabID), p.TabTitle) + } + return carapace.ActionValuesDescribed(vals...) + }) +} diff --git a/pkg/actions/tools/wezterm/window.go b/pkg/actions/tools/wezterm/window.go new file mode 100644 index 0000000000..ad6e6766a0 --- /dev/null +++ b/pkg/actions/tools/wezterm/window.go @@ -0,0 +1,21 @@ +package wezterm + +import ( + "strconv" + + "github.com/rsteube/carapace" +) + +// ActionWindows completes windows +// +// 0 +// 1 +func ActionWindows() carapace.Action { + return actionPanes(func(panes []pane) carapace.Action { + vals := make([]string, 0) + for _, p := range panes { + vals = append(vals, strconv.Itoa(p.WindowID), p.WindowTitle) + } + return carapace.ActionValuesDescribed(vals...) + }) +}