Skip to content

Commit

Permalink
Merge pull request #1149 from rsteube/tmux-breakpane
Browse files Browse the repository at this point in the history
tmux: break-pane
  • Loading branch information
rsteube authored May 19, 2022
2 parents e95dad9 + d2b972b commit a25d86f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 26 deletions.
33 changes: 33 additions & 0 deletions completers/tmux_completer/cmd/breakPane.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/tmux"
"github.com/spf13/cobra"
)

var breakPaneCmd = &cobra.Command{
Use: "break-pane",
Short: "break a pane from an existing into a new window",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(breakPaneCmd).Standalone()

breakPaneCmd.Flags().StringS("F", "F", "", "specify output format")
breakPaneCmd.Flags().BoolS("P", "P", false, "print information of new window after it has been created")
breakPaneCmd.Flags().BoolS("a", "a", false, "move window to next index after")
breakPaneCmd.Flags().BoolS("b", "b", false, "move window to next index before")
breakPaneCmd.Flags().BoolS("d", "d", false, "don't make the new window become the active one")
breakPaneCmd.Flags().StringS("n", "n", "", "specify window name")
breakPaneCmd.Flags().StringS("s", "s", "", "specify source pane")
breakPaneCmd.Flags().StringS("t", "t", "", "specify destination window")
rootCmd.AddCommand(breakPaneCmd)

// TODO output format
carapace.Gen(breakPaneCmd).FlagCompletion(carapace.ActionMap{
"s": tmux.ActionPanes(),
"t": tmux.ActionWindows(),
})
}
26 changes: 0 additions & 26 deletions completers/tmux_completer/cmd/breakPane_generated.go

This file was deleted.

22 changes: 22 additions & 0 deletions pkg/actions/tools/tmux/pane.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package tmux

import (
"strings"

"github.com/rsteube/carapace"
)

// ActionPanes completes panes
func ActionPanes() carapace.Action {
return carapace.ActionExecCommand("tmux", "list-panes")(func(output []byte) carapace.Action {
lines := strings.Split(string(output), "\n")

vals := make([]string, 0)
for _, line := range lines {
if splitted := strings.SplitN(line, ": ", 2); len(splitted) == 2 {
vals = append(vals, splitted...)
}
}
return carapace.ActionValuesDescribed(vals...)
})
}

0 comments on commit a25d86f

Please sign in to comment.