fix: add error checking while starting tmux floating window

This commit is contained in:
Patryk Hegenberg 2024-12-25 08:53:08 +01:00
parent 9812ae48d6
commit f7e621abe0

11
main.go
View file

@ -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
}
}
}