diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2025-08-06 15:48:48 -0500 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2025-08-06 15:48:48 -0500 |
| commit | da59e4b84427f1add813a73472bee2d5b32c210d (patch) | |
| tree | 7d5dfc7e543cb08f3848625737f6eb64a58db18a | |
| parent | 6cdf366f6c5f47410ecbe22d8678d06852dc47d9 (diff) | |
add projects menu
| -rw-r--r-- | broot-sessionizer/README.md | 8 | ||||
| -rwxr-xr-x | broot-sessionizer/menu.sh | 18 |
2 files changed, 25 insertions, 1 deletions
diff --git a/broot-sessionizer/README.md b/broot-sessionizer/README.md index 48781a1..b4273a9 100644 --- a/broot-sessionizer/README.md +++ b/broot-sessionizer/README.md @@ -24,5 +24,11 @@ Next, on the line that says `external =` in `broot_cfg.sh`, replace `~/.config/t Now we can add our keybinding to launch it: ```sh -bind-key -n C-f run-shell "${scriptsDir}/minibuffer.sh -d '$HOME' '~/.config/tmux/m/broot-sessionizer/launch.sh'" +bind-key -n C-f run-shell "~/.config/tmux/m/minibuffer.sh -d '$HOME' '~/.config/tmux/m/broot-sessionizer/launch.sh'" ``` + +Optionally, you can create a binding to the menu instead: +```sh +bind-key -n C-p run-shell "~/.config/tmux/m/broot-sessionizer/menu.sh" +``` +The menu has the shortcut `p` to open the sessionizer, along with shortcuts for opening active sessions. diff --git a/broot-sessionizer/menu.sh b/broot-sessionizer/menu.sh new file mode 100755 index 0000000..f187992 --- /dev/null +++ b/broot-sessionizer/menu.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + +get_nth_session() { + tmux list-sessions -F "#{session_name}" | sed -n "$1 p" +} + +switch_nth_session() { + printf "switch -t $(get_nth_session "$1")" +} + +tmux display-menu -T "#[align=centre]Projects" -x "#{window_width}" -y S \ + "Switch Project" p "run-shell '$SCRIPT_DIR/../minibuffer.sh -d $HOME $SCRIPT_DIR/launch.sh'" \ + "$(get_nth_session 1)" 1 "$(switch_nth_session 1)" \ + "$(get_nth_session 2)" 2 "$(switch_nth_session 2)" \ + "$(get_nth_session 3)" 3 "$(switch_nth_session 3)" \ + "$(get_nth_session 4)" 4 "$(switch_nth_session 4)" + |
