Skip to content

Instantly share code, notes, and snippets.

@aimestereo
Created August 5, 2023 19:37
Show Gist options
  • Save aimestereo/a55e85523d59a4129b934b804fdf7e50 to your computer and use it in GitHub Desktop.
Save aimestereo/a55e85523d59a4129b934b804fdf7e50 to your computer and use it in GitHub Desktop.
zellij-sessionizer: ThePrimeagen/tmux-sessionizer but for zellij
#!/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
@aimestereo
Copy link
Author

In the end I abandoned using Zellij, why:

  1. 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
  2. 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