File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,7 +98,14 @@ var newCmd = &cobra.Command{
9898
9999 fmt .Println ()
100100 color .Green ("✓ Ready to work in %s" , worktreePath )
101- fmt .Println ("\n To switch to this worktree:" )
101+
102+ // Ask if user wants to switch to the new worktree
103+ fmt .Println ()
104+ if confirmWithDefault ("Switch to new worktree?" , true ) {
105+ return spawnWorktreeShell (worktreePath , branchName )
106+ }
107+
108+ fmt .Println ("\n To switch to this worktree later:" )
102109 color .Cyan (" git-wt switch %s" , branchName )
103110
104111 return nil
Original file line number Diff line number Diff line change @@ -44,3 +44,21 @@ func confirm(prompt string) bool {
4444 fmt .Scanln (& response )
4545 return response == "y" || response == "Y" || response == "yes" || response == "Yes"
4646}
47+
48+ // Helper to get user confirmation with configurable default
49+ func confirmWithDefault (prompt string , defaultYes bool ) bool {
50+ var response string
51+ if defaultYes {
52+ fmt .Printf ("%s [Y/n]: " , prompt )
53+ } else {
54+ fmt .Printf ("%s [y/N]: " , prompt )
55+ }
56+ fmt .Scanln (& response )
57+
58+ // Empty response uses default
59+ if response == "" {
60+ return defaultYes
61+ }
62+
63+ return response == "y" || response == "Y" || response == "yes" || response == "Yes"
64+ }
You can’t perform that action at this time.
0 commit comments