Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Oct 15, 2023
1 parent 599365f commit e54454f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/actions/tools/wezterm/pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions pkg/actions/tools/wezterm/tab.go
Original file line number Diff line number Diff line change
@@ -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...)
})
}
17 changes: 17 additions & 0 deletions pkg/actions/tools/wezterm/window.go
Original file line number Diff line number Diff line change
@@ -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...)
})
}

0 comments on commit e54454f

Please sign in to comment.