From f7e621abe0dc9b144570a8f47cd757ce61d4779a Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Wed, 25 Dec 2024 08:53:08 +0100 Subject: [PATCH 1/2] 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 + } } } -- 2.47.2 From a47bed174fd1775bd24cf2c5b8f7e34c509d92dc Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Wed, 25 Dec 2024 09:04:19 +0100 Subject: [PATCH 2/2] docs: add README.md --- README.md | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc5eafb --- /dev/null +++ b/README.md @@ -0,0 +1,101 @@ +# tmux_popup + +`tmux_popup` is a command-line tool that allows you to open various programs inside floating popups in tmux. It supports opening tmux, lazygit, harlequin, and postings programs within a tmux session as popups. This tool helps streamline your workflow by launching and interacting with these tools directly in tmux, without leaving your terminal environment. + +## Features + +- Open tmux in a floating popup. +- Open lazygit, harlequin, and postings inside tmux popups. +- Check if the required dependencies are installed. +- Customizable popup width and height. + +## Installation + +Ensure you have the following tools installed: + +- `tmux` +- `lazygit` +- `harlequin` +- `posting` + +To install the `tmux_popup` CLI tool, you can build it from source or use pre-built binaries, if available. + +### Build from Source + +1. Clone the repository: + ```bash + git clone https://github.com/yourusername/tmux_popup.git + cd tmux_popup + +2. Build the application using Go: + +```bash +go build -o tmux_popup +```` +3. Add the binary to your system's PATH for easier access. + +## Usage +Once installed, you can use the tmux_popup tool from your terminal. The basic command syntax is: + +```bash +tmux_popup [options] +```` +### Commands +- tmux: Opens a tmux popup. + +```bash +tmux_popup tmux [--width=] [--height=] +```` +- lazygit: Opens lazygit in a tmux popup. + +```bash +tmux_popup lazygit [--width=] [--height=] +```` +- harlequin: Opens harlequin in a tmux popup. + +```bash +tmux_popup harlequin [--width=] [--height=] +```` +- postings: Opens postings in a tmux popup. + +```bash +tmux_popup postings [--width=] [--height=] +```` +- check: Checks if the required dependencies are installed. + +```bash +tmux_popup check +```` +### Options +- --width: The width of the popup (e.g., 80% or 100). +- --height: The height of the popup (e.g., 80% or 100). +If you don't specify these options, default values (80% for both width and height) will be used. + +Example Usage +Open a tmux session in a floating popup: + +```bash +tmux_popup tmux +```` + +Open lazygit in a floating popup with custom width and height: + +```bash +tmux_popup lazygit --width=100 --height=70 +```` + +Check if dependencies are correctly installed: + +``` bash +tmux_popup check +```` + +### Error Handling +If you run into issues with tmux_popup, check that: + +- You have tmux, lazygit, harlequin, and posting installed and accessible in your PATH. +- You have a running tmux session. + +## License +tmux_popup is released under the MIT License. + -- 2.47.2