diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2025-08-06 16:02:32 -0500 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2025-08-06 16:02:32 -0500 |
| commit | af97a24be201f8fffe8ea73a1f1aab1e234fa1ce (patch) | |
| tree | cbeb392eba832d89ab48732dfffb518bc904fa5b | |
| parent | da59e4b84427f1add813a73472bee2d5b32c210d (diff) | |
find-file
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | find-file/README.md | 18 | ||||
| -rw-r--r-- | find-file/file.toml | 16 | ||||
| -rwxr-xr-x | find-file/launch-find-file.sh | 4 | ||||
| -rwxr-xr-x | find-file/split.sh | 11 |
5 files changed, 50 insertions, 0 deletions
@@ -13,6 +13,7 @@ What if we could have that kind of UX in tmux? ## Scripts (so far) - [`fzf-exec`](./fzf-exec/README.md): replaces the default command prompt with a vertico-style completion menu. - [`broot-sessionizer`](./broot-sessionizer/README.md): replacement for [`tmux-sessionizer`](https://github.com/theprimeagen/tmux-sessionizer) that uses the broot instead of fzf, and runs in the minibuffer. +- [`find-file`](./find-file/README.md): Menu to open a file from the current session using broot. Future ideas: - fzf-sessionizer diff --git a/find-file/README.md b/find-file/README.md new file mode 100644 index 0000000..cfee229 --- /dev/null +++ b/find-file/README.md @@ -0,0 +1,18 @@ +# `find-file.sh` +`find-file` Launches a broot menu for opening files. +- `C-s` opens the file in a new split. It will automatically choose hsplit or vsplit based on pane size +- `C-w` opens the file in a new window + +## Setup +If you haven't already, clone the repo to a know location, such as `~/.config/tmux/m`. +```sh +cd ~/.config/tmux +git clone https://github.com/bluedragon1221/tmux-minibuffer m +``` + +In `file.toml`, replace the parts that refer to `split.sh` with the correct path to split.sh. + +Now you can add a keybinding to launch `find-file`: +```sh +bind-key -n C-f run-shell "~/.config/tmux/m/minibuffer.sh '~/.config/tmux/m/find-file/launch-find-file.sh'" +``` diff --git a/find-file/file.toml b/find-file/file.toml new file mode 100644 index 0000000..46540a6 --- /dev/null +++ b/find-file/file.toml @@ -0,0 +1,16 @@ +imports = ["~/.config/broot/conf.toml"] +quit_on_last_cancel = true + +[[verbs]] +apply_to = "file" +external = ["bash", "-c", "~/.config/tmux/scripts/split.sh -c \"#{?@default-path,#{@default-path},#{pane_current_path}}\" \"hx '{file}'\""] +invocation = "tmux-split" +key = "ctrl-s" +leave_broot = true + +[[verbs]] +apply_to = "file" +external = ["tmux", "new-window", "-c", "#{?@default-path,#{@default-path},#{pane_current_path}}", "hx '{file}'"] +invocation = "tmux-window" +key = "ctrl-w" +leave_broot = true diff --git a/find-file/launch-find-file.sh b/find-file/launch-find-file.sh new file mode 100755 index 0000000..3e33032 --- /dev/null +++ b/find-file/launch-find-file.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + +broot --conf $SCRIPT_DIR/file.toml diff --git a/find-file/split.sh b/find-file/split.sh new file mode 100755 index 0000000..77a6670 --- /dev/null +++ b/find-file/split.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +width=$(tmux display -p "#{pane_width}") +height=$(tmux display -p "#{pane_height}") + +if (( $(echo "$width / $height > 2.5" | bc -l) )); then + tmux split-window -h "$@" +else + tmux split-window -v "$@" +fi + |
