From 1f039b175eeff9ffffcc34716d45db127220174a Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 20 Jul 2022 15:52:15 +0700 Subject: [PATCH] fix: Fix creating manual windows --- smug.go | 11 ++++++++--- smug_test.go | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/smug.go b/smug.go index 4d8322c..6d2bd95 100644 --- a/smug.go +++ b/smug.go @@ -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 @@ -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 diff --git a/smug_test.go b/smug_test.go index ae27e08..7fc00c6 100644 --- a/smug_test.go +++ b/smug_test.go @@ -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",