-
-
Save mazulo/c7d6bb29850b79feb9beed6612ae663d 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment