@@ -11,18 +11,22 @@ import (
1111 "github.com/spf13/cobra"
1212)
1313
14+ var killServer bool
15+
1416// killCmd represents the kill command
1517var 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
119123func 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