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 5f1552b commit bc7c09c
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
24 changes: 24 additions & 0 deletions completers/wezterm_completer/cmd/cli_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cli_listCmd = &cobra.Command{
Use: "list",
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"),
})
}
24 changes: 24 additions & 0 deletions completers/wezterm_completer/cmd/cli_listClients.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cli_listClientsCmd = &cobra.Command{
Use: "list-clients",
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"),
})
}
6 changes: 6 additions & 0 deletions completers/wezterm_completer/cmd/l.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
list windows, tabs and panes

Usage: wezterm cli list [OPTIONS]

--format <FORMAT> Controls the output format
-h, --help Print help
49 changes: 49 additions & 0 deletions pkg/actions/tools/wezterm/pane.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package wezterm

import (
"encoding/json"

"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() 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())
}

vals := make([]string, 0)
for _, p := range panes {
vals = append(vals, p.PaneID, p.Title)
}
})

}

0 comments on commit bc7c09c

Please sign in to comment.