diff options
Diffstat (limited to 'broot-sessionizer')
| -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)" + |
