fix: add error checking while starting tmux floating window
This commit is contained in:
parent
9812ae48d6
commit
f7e621abe0
1 changed files with 9 additions and 2 deletions
11
main.go
11
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue