██▓ █ ██ ██ ▄█▀ ███▄ ▄███▓ ▓█████▄ ▓█████ ██▒ █▓ ▓██▒ ██ ▓██▒ ██▄█▒ ▓██▒▀█▀ ██▒ ▒██▀ ██▌▓█ ▀▓██░ █▒ ▒██░ ▓██ ▒██░▓███▄░ ▓██ ▓██░ ░██ █▌▒███ ▓██ █▒░ ▒██░ ▓▓█ ░██░▓██ █▄ ▒██ ▒██ ░▓█▄ ▌▒▓█ ▄ ▒██ █░░ ░██████▒▒▒█████▓ ▒██▒ █▄▒██▒ ░██▒ ██▓ ░▒████▓ ░▒████▒ ▒▀█░ ░ ▒░▓ ░░▒▓▒ ▒ ▒ ▒ ▒▒ ▓▒░ ▒░ ░ ░ ▒▓▒ ▒▒▓ ▒ ░░ ▒░ ░ ░ ▐░ ░ ░ ▒ ░░░▒░ ░ ░ ░ ░▒ ▒░░ ░ ░ ░▒ ░ ▒ ▒ ░ ░ ░ ░ ░░ ░ ░ ░░░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
Zellij tricks I use
2025-06-30
fzf menu to select sessions
You can use fzf
to create a session selector, so that you can automatically
enter an existing session or create a new one.
# Opens a fzf menu to attach to an existing Zellij session
# If none exists, will just create a new one
zj() {
if ! type fzf &> /dev/null; then
echo "fzf not found, installing..."
brew install fzf
fi
local session
session=$(
{
echo "New session"
zellij list-sessions --no-formatting | awk '{print $1}'
} | fzf --exit-0 --no-sort --prompt="Select session > "
)
if [[ "$session" == "New session" ]]; then
zellij
elif [[ -n "$session" ]]; then
zellij attach "$session"
else
:
fi
}
Open a new tab with a command
You can open a new named tab, with a custom layout using a command.
Save the following as $XDG_CONFIG_HOME/zellij/layouts/git.kdl
:
layout {
tab name="git" {
pane size=1 borderless=true {
plugin location="zellij:tab-bar"
}
pane {
command "lazygit"
}
pane size=2 borderless=true {
plugin location="zellij:status-bar"
}
}
}
Then add the alias to your ~/.zaliases
file:
alias zj-git='nocorrect zellij action new-tab --name git --layout git'
Now if you type in zj-git
, it will open a new tab called "git" with lazygit
running.
Open a tab with panes suspended
I can create a layout with panes that are suspended. For example, the following
command runs make run
then make sh
which starts the Docker services starts
an interactive shell inside them;
layout {
tab name="make" {
pane size=1 borderless=true {
plugin location="zellij:tab-bar"
}
pane split_direction="vertical" {
pane command="make" start_suspended=true {
args "start";
}
pane command="make" start_suspended=true {
args "sh";
}
}
pane size=2 borderless=true {
plugin location="zellij:status-bar"
}
}
}
Because make start
subscribes me to the logs, I don't want to run make sh
in
the same pane.