Created
August 5, 2023 19:37
-
-
Save aimestereo/a55e85523d59a4129b934b804fdf7e50 to your computer and use it in GitHub Desktop.
zellij-sessionizer: ThePrimeagen/tmux-sessionizer but for zellij
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# set your own root folders, all children folders will become options for in sessionizer menu | |
root_folders="$HOME/projects $HOME/work $HOME/.config" | |
function attach_session() { | |
local session_root=$1 | |
local session_name=$(basename "$session_root" | tr . _) | |
cd $session_root | |
zellij attach --create $session_name | |
} | |
quit_option="=== Quit sessionizer ===" | |
last_session="" | |
while true; do | |
selected_option=$( (echo $quit_option && find $root_folders -mindepth 1 -maxdepth 1 -type d) | fzf) | |
if [[ $selected_option == $quit_option ]]; then | |
exit 0 | |
fi | |
if [[ -z $selected_option && -z $last_session ]]; then | |
exit 0 | |
fi | |
if [[ -z $selected_option ]]; then | |
attach_session $last_session | |
else | |
last_session=$selected_option | |
attach_session $selected_option | |
fi | |
done |
@Lilja to Quit fzf, you need to select bottom option - === Quit sessionizer ===
What you point out is why this script exists. Zellij doesn't support switching sessions, so this script emulate it. By exiting Zellij you end up in project picker to select another project and open its session or create new one.
In the end I abandoned using Zellij, why:
- must have for me, that's impossible to emulate in Zellij:
- tmux provides nice way for fast switching between current and previous session
- fzf is running inside tmux, so if I change my mind, I can just press
Esc
to return to current session
- nice things:
- tmux covers all my needs or Zellij doesn't provide anything new, that's useful for me
- I don't like Zellij view: all this green frames or lines, and I don't see easy way to customize it
- I don't like keybinding: there're a lot of them and they conflict with what I set in Vim, so I need to always keep Zellij in locked mode and modify keybinding for all mode transitions: a lot of work, complex custom config. I don't see a need in all these mode transitions in the first place
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found one bug(?)
$ exit
<Esc>
doesn't close menu.