Files
nixos-config/modules/features/zellij.nix

385 lines
12 KiB
Nix
Raw Normal View History

2026-04-04 16:46:30 -04:00
{
2026-04-11 14:19:46 -04:00
inputs,
...
}:
{
flake.modules.homeManager.zellij =
{ pkgs, ... }:
{
programs.zellij =
let
mod = "Alt"; # Can be one of "Ctrl", "Alt", "Shift", "Super"
action = name: { ${name} = { }; };
actionWith = name: args: { ${name}._args = args; };
switchMode = mode: actionWith "SwitchToMode" [ mode ];
bind =
{ keys, actions }:
{
bind = {
_args = [ keys ];
_children = actions;
};
};
modeBinds = mode: bindings: {
${mode}._children = map bind bindings;
};
sharedExcept = modes: bindings: {
shared_except = {
_args = modes;
_children = map bind bindings;
2026-04-04 16:46:30 -04:00
};
2026-04-11 14:19:46 -04:00
};
in
{
enable = true;
enableZshIntegration = true;
settings = {
theme = "catppuccin-mocha";
show_startup_tips = false;
default_mode = "locked";
2026-04-04 16:46:30 -04:00
2026-04-11 14:19:46 -04:00
ui._children = [
2026-04-04 16:46:30 -04:00
{
2026-04-11 14:19:46 -04:00
pane_frames._children = [
{ rounded_corners = true; }
2026-04-04 16:46:30 -04:00
];
}
2026-04-11 14:19:46 -04:00
];
keybinds = {
_props = {
clear-defaults = true;
};
_children = [
(modeBinds "locked" [
{
keys = "${mod} q";
actions = [
(switchMode "Normal")
];
}
])
(sharedExcept
[ "locked" "normal" "renamepane" "renametab" ]
[
{
keys = "Esc";
actions = [ (switchMode "Normal") ];
}
]
)
(modeBinds "normal" [
2026-04-04 16:46:30 -04:00
{
2026-04-11 14:19:46 -04:00
keys = "Esc";
actions = [ (switchMode "Locked") ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "h";
actions = [ (actionWith "MoveFocusOrTab" [ "Left" ]) ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "j";
actions = [ (actionWith "MoveFocus" [ "Down" ]) ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "k";
actions = [ (actionWith "MoveFocus" [ "Up" ]) ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "l";
actions = [ (actionWith "MoveFocusOrTab" [ "Right" ]) ];
2026-04-04 16:46:30 -04:00
}
2026-04-11 14:19:46 -04:00
{
keys = "H";
actions = [ (action "GoToPreviousTab") ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "L";
actions = [ (action "GoToNextTab") ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "p";
actions = [ (switchMode "Pane") ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "t";
actions = [ (switchMode "Tab") ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "r";
actions = [ (switchMode "Resize") ];
2026-04-04 16:46:30 -04:00
}
2026-04-11 14:19:46 -04:00
])
(modeBinds "pane" [
2026-04-04 16:46:30 -04:00
{
2026-04-11 14:19:46 -04:00
keys = "h";
actions = [ (actionWith "MovePane" [ "Left" ]) ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "j";
actions = [ (actionWith "MovePane" [ "Down" ]) ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "k";
actions = [ (actionWith "MovePane" [ "Up" ]) ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "l";
actions = [ (actionWith "MovePane" [ "Right" ]) ];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "s";
actions = [
(actionWith "NewPane" [ "stacked" ])
];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "d";
actions = [
(actionWith "NewPane" [ "down" ])
];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "r";
actions = [
(actionWith "NewPane" [ "right" ])
];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "x";
actions = [
(action "CloseFocus")
];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "e";
actions = [
(action "TogglePaneEmbedOrFloating")
];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "f";
actions = [
(action "ToggleFocusFullscreen")
];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "c";
actions = [
(switchMode "RenamePane")
(actionWith "PaneNameInput" [ 0 ])
];
2026-04-04 16:46:30 -04:00
}
{
2026-04-11 14:19:46 -04:00
keys = "w";
actions = [
(action "ToggleFloatingPanes")
];
2026-04-04 16:46:30 -04:00
}
2026-04-11 14:19:46 -04:00
{
keys = "[";
actions = [
(action "BreakPaneLeft")
];
}
{
keys = "]";
actions = [
(action "BreakPaneRight")
];
}
])
(modeBinds "tab" [
{
keys = "h";
actions = [ (actionWith "MoveTab" [ "Left" ]) ];
}
{
keys = "l";
actions = [ (actionWith "MoveTab" [ "Right" ]) ];
}
{
keys = "b";
actions = [
(action "BreakPane")
];
}
{
keys = "x";
actions = [
(action "CloseTab")
];
}
{
keys = "n";
actions = [
(action "NewTab")
];
}
{
keys = "c";
actions = [
(switchMode "RenameTab")
(actionWith "TabNameInput" [ 0 ])
];
}
])
(modeBinds "renamepane" [
{
keys = "Enter";
actions = [
(switchMode "Pane")
];
}
{
keys = "Esc";
actions = [
(action "UndoRenamePane")
(switchMode "Pane")
];
}
])
(modeBinds "renametab" [
{
keys = "Enter";
actions = [
(switchMode "Tab")
];
}
{
keys = "Esc";
actions = [
(action "UndoRenameTab")
(switchMode "Tab")
];
}
])
(modeBinds "resize" [
{
keys = "h";
actions = [ (actionWith "Resize" [ "Increase Left" ]) ];
}
{
keys = "j";
actions = [ (actionWith "Resize" [ "Increase Down" ]) ];
}
{
keys = "k";
actions = [ (actionWith "Resize" [ "Increase Up" ]) ];
}
{
keys = "l";
actions = [ (actionWith "Resize" [ "Increase Right" ]) ];
}
{
keys = "H";
actions = [ (actionWith "Resize" [ "Decrease Right" ]) ];
}
{
keys = "J";
actions = [ (actionWith "Resize" [ "Decrease Up" ]) ];
}
{
keys = "K";
actions = [ (actionWith "Resize" [ "Decrease Down" ]) ];
}
{
keys = "L";
actions = [ (actionWith "Resize" [ "Decrease Left" ]) ];
}
{
keys = "+";
actions = [ (actionWith "Resize" [ "Increase" ]) ];
}
{
keys = "=";
actions = [ (actionWith "Resize" [ "Increase" ]) ];
}
{
keys = "-";
actions = [ (actionWith "Resize" [ "Decrease" ]) ];
}
])
];
};
2026-04-04 16:46:30 -04:00
2026-04-11 14:19:46 -04:00
plugins = {
compact-bar = {
_props = {
location = "zellij:compact-bar";
};
2026-04-04 16:46:30 -04:00
};
};
2026-04-11 14:19:46 -04:00
# simplified_ui = true;
# pane_frames = true;
copy_on_select = true;
};
2026-04-04 16:46:30 -04:00
};
2026-04-11 14:19:46 -04:00
xdg.configFile."zellij/layouts/default.kdl".text =
let
zjstatus = inputs.zjstatus.packages.${pkgs.stdenv.hostPlatform.system}.default;
in
''
layout {
default_tab_template {
pane size=2 borderless=true {
plugin location="file:${zjstatus}/bin/zjstatus.wasm" {
hide_frame_except_for_search "true"
border_enabled "true"
border_char ""
border_format "#[fg=#6C7086]{char}"
border_position "bottom"
format_left " {mode} #[fg=#6c7086] #[fg=#eba0ac] {session}"
format_center "{tabs}"
format_right ""
format_space ""
format_hide_on_overlength "true"
format_precedence "crl"
tab_normal "#[fg=#f5e0dc] {name}{fullscreen_indicator}{sync_indicator}{floating_indicator} "
tab_active "#[fg=#1e1e2e,bg=#fab387] {name}{fullscreen_indicator}{sync_indicator}{floating_indicator} "
tab_fullscreen_indicator " "
tab_sync_indicator " "
tab_floating_indicator " 󰉈"
tab_separator "#[fg=#6C7086] "
mode_normal "#[fg=#a6da95]NORMAL"
mode_locked "#[fg=#6e738d]LOCKED "
mode_resize "#[fg=#f38ba8]RESIZE"
mode_pane "#[fg=#89b4fa]PANE"
mode_tab "#[fg=#b4befe]TAB"
mode_scroll "#[fg=#f9e2af]SCROLL"
mode_enter_search "#[fg=#8aadf4]ENT-SEARCH"
mode_search "#[fg=#8aadf4]SEARCHARCH"
mode_rename_tab "#[fg=#b4befe]RENAME-TAB"
mode_rename_pane "#[fg=#89b4fa]RENAME-PANE"
mode_session "#[fg=#74c7ec]SESSION"
mode_move "#[fg=#f5c2e7]MOVE"
mode_prompt "#[fg=#8aadf4]PROMPT"
mode_tmux "#[fg=#f5a97f]TMUX"
command_host_command "uname -n"
command_host_format "{stdout}"
command_host_interval "0"
command_host_rendermode "static"
command_user_command "whoami"
command_user_format "{stdout}"
command_user_interval "0"
command_user_rendermode "static"
}
}
children
}
}
'';
};
2026-04-04 16:46:30 -04:00
}