From 3abfabb1b4e86d98b2b74acc42e66c59ca891684 Mon Sep 17 00:00:00 2001 From: James Walker Date: Thu, 2 Dec 2021 16:52:06 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20OnProjectStart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit should only run when session is created. --- tmux/project.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tmux/project.go b/tmux/project.go index dda15d3..a1c75f5 100644 --- a/tmux/project.go +++ b/tmux/project.go @@ -29,25 +29,25 @@ func StartProject(name string) { os.Exit(1) } - // Run startup commands - if len(p.OnProjectStart) > 0 { - for _, command := range p.OnProjectStart { - args := strings.Fields(command) - cmd := exec.Command(args[0], args[1:]...) - cmd.Dir = p.GetRoot() - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err := cmd.Run() - if err != nil { - fmt.Println("Unable to run start command:", err) - os.Exit(1) - } - } - } - tmux := CreateTmux(false) if !sessionExists(name) { + // Run startup commands + if len(p.OnProjectStart) > 0 { + for _, command := range p.OnProjectStart { + args := strings.Fields(command) + cmd := exec.Command(args[0], args[1:]...) + cmd.Dir = p.GetRoot() + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + fmt.Println("Unable to run start command:", err) + os.Exit(1) + } + } + } + tmux.Run("new-session", "-d", "-s", name, "-n", p.Windows[0].Name, "-c", p.Windows[0].Root) for index, window := range p.Windows {