From f7e621abe0dc9b144570a8f47cd757ce61d4779a Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Wed, 25 Dec 2024 08:53:08 +0100 Subject: [PATCH] fix: add error checking while starting tmux floating window --- main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 0bee623..c587f05 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "log/slog" "os" "os/exec" "strings" @@ -91,7 +92,10 @@ func openPopup(sessionName, command string, width, height string) { } if strings.TrimSpace(string(currentSession)) == sessionName { - exec.Command("tmux", "detach-client").Run() + if err := exec.Command("tmux", "detach-client").Run(); err != nil { + slog.Error("Failed to execute tmux command", "error", err) + return + } } else { args := []string{"popup", "-d", "#{pane_current_path}", "-xC", "-yC", fmt.Sprintf("-w%s", width), fmt.Sprintf("-h%s", height), "-E"} if command == "" { @@ -99,7 +103,10 @@ func openPopup(sessionName, command string, width, height string) { } else { args = append(args, fmt.Sprintf("tmux attach -t %s || tmux new -s %s '%s'", sessionName, sessionName, command)) } - exec.Command("tmux", args...).Run() + if err := exec.Command("tmux", args...).Run(); err != nil { + slog.Error("Failed to execute tmux command", "error", err) + return + } } }