aboutsummaryrefslogtreecommitdiff
path: root/broot-sessionizer
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2025-08-06 09:17:43 -0500
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2025-08-06 09:17:43 -0500
commit6cdf366f6c5f47410ecbe22d8678d06852dc47d9 (patch)
treeb2df3607f7ed6426604d2f49487e3ac16f3faf19 /broot-sessionizer
parentcbbfb6ca64cbf2a34fd786c10a958b3a76fdbbf2 (diff)
broot-sessionizer
Diffstat (limited to 'broot-sessionizer')
-rw-r--r--broot-sessionizer/README.md28
-rw-r--r--broot-sessionizer/broot_cfg.toml9
-rwxr-xr-xbroot-sessionizer/launch.sh4
-rwxr-xr-xbroot-sessionizer/sessionizer.sh11
4 files changed, 52 insertions, 0 deletions
diff --git a/broot-sessionizer/README.md b/broot-sessionizer/README.md
new file mode 100644
index 0000000..48781a1
--- /dev/null
+++ b/broot-sessionizer/README.md
@@ -0,0 +1,28 @@
+# `broot-sessionizer`
+A replacement for [`tmux-sessionizer`](https://github.com/theprimeagen/tmux-sessionizer) that uses the broot instead of fzf, and runs in the minibuffer.
+
+<a href="https://asciinema.org/a/2qp4RkHfbNzNHm3BQsWUrrTy9" target="_blank"><img src="https://asciinema.org/a/2qp4RkHfbNzNHm3BQsWUrrTy9.svg" /></a>
+
+For those unfamiliar, here is the basic sessionizer workflow:
+- You have one tmux session for every project that you're working on.
+- The script presents you with a menu to select one of your projects from
+ - If a tmux session for that project already exists, switch to it
+ - Otherwise, create the session and switch to it
+
+Differences from tmux-sessionizer:
+- lets you pick any directory in the filesystem, instead of from a set list of projects.
+- sets @default-path in the session to the path the user selects (useful for scripting)
+
+## Setup
+If you haven't already, clone this repo to a know location, such as `~/.config/tmux/m`.
+```sh
+cd ~/.config/tmux
+git clone https://bluedragon1221/tmux-minibuffer m
+```
+
+Next, on the line that says `external =` in `broot_cfg.sh`, replace `~/.config/tmux/sessionizer.sh` with the correct path to `sessionizer.sh`.
+
+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'"
+```
diff --git a/broot-sessionizer/broot_cfg.toml b/broot-sessionizer/broot_cfg.toml
new file mode 100644
index 0000000..f25d67f
--- /dev/null
+++ b/broot-sessionizer/broot_cfg.toml
@@ -0,0 +1,9 @@
+imports = ["~/.config/broot/conf.toml"]
+quit_on_last_cancel = true
+
+[[verbs]]
+apply_to = "directory"
+external = "bash -c -- \"~/.config/tmux/sessionizer.sh '{file}'\""
+invocation = "sessionizer"
+key = "enter"
+leave_broot = true
diff --git a/broot-sessionizer/launch.sh b/broot-sessionizer/launch.sh
new file mode 100755
index 0000000..ad5239e
--- /dev/null
+++ b/broot-sessionizer/launch.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
+
+broot --only-folders --conf "$SCRIPT_DIR/broot_cfg.toml"
diff --git a/broot-sessionizer/sessionizer.sh b/broot-sessionizer/sessionizer.sh
new file mode 100755
index 0000000..b3b327b
--- /dev/null
+++ b/broot-sessionizer/sessionizer.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+selected_dir="$1"
+
+session_name="$(basename "$selected_dir" | tr '.' '_')"
+if tmux list-sessions -F '#{session_name}' | grep -vqx "$session_name"; then
+ tmux new-session -ds "$session_name" -c "$selected_dir"
+ tmux set-option -t "$session_name" @default-path "$selected_dir"
+fi
+
+tmux switch -t "$session_name"
+