Skip to content

Commit

Permalink
fix: Fix creating manual windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaaaan committed Jul 20, 2022
1 parent 5d4e548 commit 1307da4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions smug.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (smug Smug) Start(config *Config, options *Options, context Context) error
}
}

if !options.InsideCurrentSession {
if !options.InsideCurrentSession && !sessionExists {
err := smug.tmux.KillWindow(sessionName + defaultWindowName)
if err != nil {
return err
Expand All @@ -209,8 +209,13 @@ func (smug Smug) Start(config *Config, options *Options, context Context) error
}
}

if len(windows) == 0 && len(config.Windows) > 0 && !options.Detach {
return smug.switchOrAttach(sessionName+config.Windows[0].Name, attach, context.InsideTmuxSession)
if len(config.Windows) > 0 && !options.Detach {
w := config.Windows[0].Name
if len(options.Windows) > 0 {
w = options.Windows[0]
}

return smug.switchOrAttach(sessionName+w, attach, context.InsideTmuxSession)
}

return nil
Expand Down
1 change: 1 addition & 0 deletions smug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ var testTable = map[string]struct {
"tmux select-layout -t xyz even-horizontal",
"tmux kill-window -t ses:smug_def",
"tmux move-window -r -s ses: -t ses:",
"tmux attach -d -t ses:win2",
},
[]string{
"tmux kill-window -t ses:win2",
Expand Down

0 comments on commit 1307da4

Please sign in to comment.