-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
|
||
} |