Skip to content

Commit 0b24db3

Browse files
authored
Merge pull request #36 from Pairadux/fix/switch-empty-notice
fix(switch): prompt for user confirmation when no other sessions found
2 parents e6bc913 + d5448bc commit 0b24db3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd/switch.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/spf13/cobra"
1111
)
1212

13+
var skipEnter bool
14+
1315
// switchCmd represents the switch command
1416
var switchCmd = &cobra.Command{
1517
Use: "switch [SESSION]",
@@ -34,7 +36,11 @@ If no other sessions found, exit.`,
3436
sessions := tmux.GetSessionsExceptCurrent(currentSession)
3537

3638
if len(sessions) == 0 {
37-
fmt.Println("No other sessions available. Use 'muxly' to start a new session.")
39+
fmt.Println("No other sessions available. Press 'Enter' to continue...")
40+
_, err := fmt.Scanln()
41+
if err != nil {
42+
return fmt.Errorf("input closed: %w", err)
43+
}
3844
return nil
3945
}
4046

@@ -65,4 +71,5 @@ If no other sessions found, exit.`,
6571

6672
func init() {
6773
rootCmd.AddCommand(switchCmd)
74+
rootCmd.Flags().BoolVarP(&skipEnter, "skip-enter", "s", false, "Skip the 'press Enter' confirmation prompt when no other sessions found")
6875
}

0 commit comments

Comments
 (0)