From e54454fbb279485b971fcdd48853562752d5e7bb Mon Sep 17 00:00:00 2001 From: rsteube Date: Mon, 16 Oct 2023 01:33:49 +0200 Subject: [PATCH] tmp --- pkg/actions/tools/wezterm/pane.go | 7 ++++++- pkg/actions/tools/wezterm/tab.go | 17 +++++++++++++++++ pkg/actions/tools/wezterm/window.go | 17 +++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 pkg/actions/tools/wezterm/tab.go create mode 100644 pkg/actions/tools/wezterm/window.go diff --git a/pkg/actions/tools/wezterm/pane.go b/pkg/actions/tools/wezterm/pane.go index 1564634869..5e9e796834 100644 --- a/pkg/actions/tools/wezterm/pane.go +++ b/pkg/actions/tools/wezterm/pane.go @@ -34,13 +34,18 @@ type pane struct { TtyName string `json:"tty_name"` } -func ActionPanes() carapace.Action { +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) + }) +} +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) diff --git a/pkg/actions/tools/wezterm/tab.go b/pkg/actions/tools/wezterm/tab.go new file mode 100644 index 0000000000..137189ffc9 --- /dev/null +++ b/pkg/actions/tools/wezterm/tab.go @@ -0,0 +1,17 @@ +package wezterm + +import ( + "strconv" + + "github.com/rsteube/carapace" +) + +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..06f1c057eb --- /dev/null +++ b/pkg/actions/tools/wezterm/window.go @@ -0,0 +1,17 @@ +package wezterm + +import ( + "strconv" + + "github.com/rsteube/carapace" +) + +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...) + }) +}