Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,9 @@ _install_zellij_inner() {
scroll_buffer_size 50000
pane_frames false
auto_layout true
on_force_close "quit"
// "detach" not "quit" — a dropped client (ssh/mosh dying) must not kill
// the session and everything running in it
on_force_close "detach"
simplified_ui true
session_serialization true
support_kitty_keyboard_protocol true
Expand Down Expand Up @@ -1103,16 +1105,21 @@ _install_zellij_inner() {
};
}

// Prefix-style bindings via Ctrl+Space (tmux-like leader)
// Prefix-style bindings via Ctrl+Space (tmux-like leader).
// Ctrl+b as well: Ctrl+Space is a NUL byte some clients never
// deliver (iPadOS grabs it for input-source switching)
bind "Ctrl Space" { SwitchToMode "Tmux"; }
bind "Ctrl b" { SwitchToMode "Tmux"; }
}

locked {
bind "Ctrl Space" { SwitchToMode "Normal"; }
bind "Ctrl b" { SwitchToMode "Normal"; }
}

tmux {
bind "Ctrl Space" { SwitchToMode "Normal"; }
bind "Ctrl b" { SwitchToMode "Normal"; }
bind "Esc" { SwitchToMode "Normal"; }

// Pane splitting (h=horizontal, v=vertical — matching tmux)
Expand Down Expand Up @@ -1161,6 +1168,9 @@ _install_zellij_inner() {

// Enter scroll/copy mode (vi-style — like tmux [ )
bind "[" { SwitchToMode "Scroll"; }

// Keybinding help — floating configuration plugin
bind "?" { LaunchOrFocusPlugin "configuration" { floating true; }; SwitchToMode "Normal"; }
}

// ── Scroll mode (vi-style copy mode) ────────────────────────
Expand Down Expand Up @@ -1217,6 +1227,7 @@ _install_zellij_inner() {
// Allow Ctrl+Space to return to normal from any non-normal mode
shared_except "normal" "locked" "tmux" {
bind "Ctrl Space" { SwitchToMode "Normal"; }
bind "Ctrl b" { SwitchToMode "Normal"; }
}
}
ZELLIJCONF
Expand All @@ -1236,9 +1247,23 @@ _install_zellij_inner() {
fi
}

_ensure_zellij_defaults() {
local conf="$HOME/.config/zellij/config.kdl"
[ -f "$conf" ] || return 0
sed -i 's/^on_force_close "quit"/on_force_close "detach"/' "$conf"
if ! grep -q 'bind "?"' "$conf"; then
sed -i '/bind "\[" { SwitchToMode "Scroll"; }/a\ bind "?" { LaunchOrFocusPlugin "configuration" { floating true; }; SwitchToMode "Normal"; }' "$conf"
fi
if ! grep -q 'bind "Ctrl b" { SwitchToMode "Tmux"; }' "$conf"; then
sed -i 's|^\(\s*\)bind "Ctrl Space" { SwitchToMode "Tmux"; }$|&\n\1bind "Ctrl b" { SwitchToMode "Tmux"; }|' "$conf"
sed -i 's|^\(\s*\)bind "Ctrl Space" { SwitchToMode "Normal"; }$|&\n\1bind "Ctrl b" { SwitchToMode "Normal"; }|' "$conf"
fi
}

install_zellij() {
if command -v zellij &>/dev/null; then echo "Zellij already installed, skipping."; return 0; fi
if command -v zellij &>/dev/null; then echo "Zellij already installed, skipping."; _ensure_zellij_defaults; return 0; fi
run_with_spinner "Installing Zellij..." _install_zellij_inner
_ensure_zellij_defaults
}

for mux in $(echo "$mux_list" | tr ',' ' '); do
Expand Down