Skip to content

Commit e6bc913

Browse files
authored
Merge pull request #35 from Pairadux/feat/kill-server-flag
Feat/kill server flag
2 parents 3f0cca6 + 190030c commit e6bc913

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

cmd/kill.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ import (
1111
"github.com/spf13/cobra"
1212
)
1313

14+
var killServer bool
15+
1416
// killCmd represents the kill command
1517
var killCmd = &cobra.Command{
16-
Use: "kill",
17-
Short: "Kill the current session and replace with another",
18-
Long: `Kill the current session and replace with another
19-
20-
A picker list of alternative sessions will be displayed to switch the current session.
21-
If there are no other sessions however, the default sessions configured in the config file will be used.`,
18+
Use: "kill [SESSION]",
19+
Short: "Kill a tmux session and switch to another",
20+
Long: `Kill a tmux session and switch to another.
21+
22+
If SESSION is provided, the current session is killed and the client switches to SESSION.
23+
Otherwise, a picker list of active sessions is displayed to choose a replacement.
24+
If no other sessions exist, a new session is created from the primary template or the tmux server is killed.`,
25+
Args: cobra.MaximumNArgs(1),
2226
RunE: func(cmd *cobra.Command, args []string) error {
2327
currentSession := tmux.GetCurrentTmuxSession()
2428

25-
if currentSession == "" {
29+
if currentSession == "" || killServer {
2630
var killServer bool
2731
form := forms.ConfirmationForm("Kill tmux server?", "This will terminate all tmux sessions.", &killServer)
2832

@@ -118,4 +122,6 @@ If there are no other sessions however, the default sessions configured in the c
118122

119123
func init() {
120124
rootCmd.AddCommand(killCmd)
125+
rootCmd.PersistentFlags().BoolVarP(&killServer, "kill-server", "k", false, "Kill tmux server (rather than current session)")
121126
}
127+

0 commit comments

Comments
 (0)