zellij: now mod key is based on config profile

This commit is contained in:
Tigor Hutasuhut 2024-08-04 15:51:33 +07:00
parent bedec6e2e4
commit b30258f247
2 changed files with 167 additions and 158 deletions

View file

@ -6,7 +6,7 @@ let
url = "https://github.com/cristiand391/zj-quit/releases/download/0.3.0/zj-quit.wasm";
hash = "sha256-f1D3cDuLRZ5IqY3IGq6UYSEu1VK54TwmkmwWaxVQD2A=";
};
zstatus = pkgs.fetchurl {
zj-status = pkgs.fetchurl {
url = "https://github.com/dj95/zjstatus/releases/download/v0.17.0/zjstatus.wasm";
hash = "sha256-IgTfSl24Eap+0zhfiwTvmdVy/dryPxfEF7LhVNVXe+U";
};
@ -52,166 +52,170 @@ in
''
);
home.file.".config/zellij/config.kdl".text = /*kdl*/ ''
theme "catppuccin-mocha";
home.file.".config/zellij/config.kdl".text =
let
mod = cfg.mod;
in
/*kdl*/ ''
theme "catppuccin-mocha";
plugins {
zj-quit location="file:${plugins.zj-quit}";
}
keybinds clear-defaults=true {
shared_except "locked" {
bind "Ctrl q" {
LaunchOrFocusPlugin "zj-quit" {
floating true
};
}
plugins {
zj-quit location="file:${plugins.zj-quit}";
}
normal {
bind "Ctrl a" { SwitchToMode "tmux"; }
keybinds clear-defaults=true {
shared_except "locked" {
bind "Ctrl q" {
LaunchOrFocusPlugin "zj-quit" {
floating true
};
}
}
normal {
bind "${mod}" { SwitchToMode "tmux"; }
}
locked {
bind "${mod}" { SwitchToMode "normal"; }
}
tmux {
// Switching modes
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
bind "w" { SwitchToMode "Resize"; }
bind "e" { SwitchToMode "Scroll"; }
bind "S" { SwitchToMode "Session"; }
bind "r" { SwitchToMode "RenamePane"; PaneNameInput 0; }
bind "R" { SwitchToMode "RenameTab"; TabNameInput 0; }
bind "/" { SwitchToMode "EnterSearch"; SearchInput 0; }
bind "\\" { SwitchToMode "locked"; }
// Pane management
bind "Enter" { NewPane "Right"; SwitchToMode "Normal"; };
bind "Backspace" { NewPane "Down"; SwitchToMode "Normal"; };
bind "q" { CloseFocus; SwitchToMode "Normal"; }
bind "h" { MoveFocus "Left"; SwitchToMode "Normal"; }
bind "j" { MoveFocus "Down"; SwitchToMode "Normal"; }
bind "k" { MoveFocus "Up"; SwitchToMode "Normal"; }
bind "l" { MoveFocus "Right"; SwitchToMode "Normal"; }
bind "H" { MovePane "Left"; SwitchToMode "Normal"; }
bind "J" { MovePane "Down"; SwitchToMode "Normal"; }
bind "K" { MovePane "Up"; SwitchToMode "Normal"; }
bind "L" { MovePane "Right"; SwitchToMode "Normal"; }
bind "Space" { ToggleFocusFullscreen; SwitchToMode "Normal"; }
// Tab management
bind "t" { NewTab; SwitchToMode "Normal"; }
bind "x" { CloseTab; SwitchToMode "Normal"; }
bind "1" { GoToTab 1; SwitchToMode "Normal"; }
bind "2" { GoToTab 2; SwitchToMode "Normal"; }
bind "3" { GoToTab 3; SwitchToMode "Normal"; }
bind "4" { GoToTab 4; SwitchToMode "Normal"; }
bind "5" { GoToTab 5; SwitchToMode "Normal"; }
bind "6" { GoToTab 6; SwitchToMode "Normal"; }
bind "7" { GoToTab 7; SwitchToMode "Normal"; }
bind "8" { GoToTab 8; SwitchToMode "Normal"; }
bind "9" { GoToTab 9; SwitchToMode "Normal"; }
// Session management
bind "s" {
LaunchOrFocusPlugin "session-manager" {
floating true
move_to_focused_tab true
};
SwitchToMode "Normal";
}
}
resize {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
bind "h" "Left" { Resize "Increase Left"; }
bind "j" "Down" { Resize "Increase Down"; }
bind "k" "Up" { Resize "Increase Up"; }
bind "l" "Right" { Resize "Increase Right"; }
bind "H" { Resize "Decrease Left"; }
bind "J" { Resize "Decrease Down"; }
bind "K" { Resize "Decrease Up"; }
bind "L" { Resize "Decrease Right"; }
bind "=" "+" { Resize "Increase"; }
bind "-" { Resize "Decrease"; }
}
search {
bind "/" { SwitchToMode "EnterSearch"; SearchInput 0; }
bind "Ctrl s" { SwitchToMode "Normal"; }
bind "Ctrl c" "Esc" { ScrollToBottom; SwitchToMode "Normal"; }
bind "j" "Down" { ScrollDown; }
bind "k" "Up" { ScrollUp; }
bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; }
bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; }
bind "d" { HalfPageScrollDown; }
bind "u" { HalfPageScrollUp; }
bind "n" { Search "down"; }
bind "p" { Search "up"; }
bind "c" { SearchToggleOption "CaseSensitivity"; }
bind "w" { SearchToggleOption "Wrap"; }
bind "o" { SearchToggleOption "WholeWord"; }
}
entersearch {
bind "Ctrl c" "Esc" { SwitchToMode "Scroll"; }
bind "Enter" { SwitchToMode "Search"; }
}
scroll {
bind "Esc" { SwitchToMode "Normal"; }
bind "e" { EditScrollback; SwitchToMode "Normal"; }
bind "/" { SwitchToMode "EnterSearch"; SearchInput 0; }
bind "Ctrl c" { ScrollToBottom; SwitchToMode "Normal"; }
bind "j" "Down" { ScrollDown; }
bind "k" "Up" { ScrollUp; }
bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; }
bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; }
bind "d" { HalfPageScrollDown; }
bind "u" { HalfPageScrollUp; }
}
session {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
bind "d" { Detach; }
bind "S" {
LaunchOrFocusPlugin "session-manager" {
floating true
move_to_focused_tab true
};
SwitchToMode "Normal"
}
bind "c" {
LaunchOrFocusPlugin "configuration" {
floating true
move_to_focused_tab true
};
SwitchToMode "Normal"
}
}
renametab {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
// bind "Esc" { UndoRenameTab; SwitchToMode "Tab"; }
}
renamepane {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
// bind "Esc" { UndoRenamePane; SwitchToMode "Pane"; }
}
// Unused modes is only given escape keys to return to normal mode.
pane {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
}
move {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
}
}
locked {
bind "Ctrl a" { SwitchToMode "normal"; }
}
tmux {
// Switching modes
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
bind "w" { SwitchToMode "Resize"; }
bind "e" { SwitchToMode "Scroll"; }
bind "S" { SwitchToMode "Session"; }
bind "r" { SwitchToMode "RenamePane"; PaneNameInput 0; }
bind "R" { SwitchToMode "RenameTab"; TabNameInput 0; }
bind "/" { SwitchToMode "EnterSearch"; SearchInput 0; }
bind "\\" { SwitchToMode "locked"; }
// Pane management
bind "Enter" { NewPane "Right"; SwitchToMode "Normal"; };
bind "Backspace" { NewPane "Down"; SwitchToMode "Normal"; };
bind "q" { CloseFocus; SwitchToMode "Normal"; }
bind "h" { MoveFocus "Left"; SwitchToMode "Normal"; }
bind "j" { MoveFocus "Down"; SwitchToMode "Normal"; }
bind "k" { MoveFocus "Up"; SwitchToMode "Normal"; }
bind "l" { MoveFocus "Right"; SwitchToMode "Normal"; }
bind "H" { MovePane "Left"; SwitchToMode "Normal"; }
bind "J" { MovePane "Down"; SwitchToMode "Normal"; }
bind "K" { MovePane "Up"; SwitchToMode "Normal"; }
bind "L" { MovePane "Right"; SwitchToMode "Normal"; }
bind "Space" { ToggleFocusFullscreen; SwitchToMode "Normal"; }
// Tab management
bind "t" { NewTab; SwitchToMode "Normal"; }
bind "x" { CloseTab; SwitchToMode "Normal"; }
bind "1" { GoToTab 1; SwitchToMode "Normal"; }
bind "2" { GoToTab 2; SwitchToMode "Normal"; }
bind "3" { GoToTab 3; SwitchToMode "Normal"; }
bind "4" { GoToTab 4; SwitchToMode "Normal"; }
bind "5" { GoToTab 5; SwitchToMode "Normal"; }
bind "6" { GoToTab 6; SwitchToMode "Normal"; }
bind "7" { GoToTab 7; SwitchToMode "Normal"; }
bind "8" { GoToTab 8; SwitchToMode "Normal"; }
bind "9" { GoToTab 9; SwitchToMode "Normal"; }
// Session management
bind "s" {
LaunchOrFocusPlugin "session-manager" {
floating true
move_to_focused_tab true
};
SwitchToMode "Normal";
}
}
resize {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
bind "h" "Left" { Resize "Increase Left"; }
bind "j" "Down" { Resize "Increase Down"; }
bind "k" "Up" { Resize "Increase Up"; }
bind "l" "Right" { Resize "Increase Right"; }
bind "H" { Resize "Decrease Left"; }
bind "J" { Resize "Decrease Down"; }
bind "K" { Resize "Decrease Up"; }
bind "L" { Resize "Decrease Right"; }
bind "=" "+" { Resize "Increase"; }
bind "-" { Resize "Decrease"; }
}
search {
bind "/" { SwitchToMode "EnterSearch"; SearchInput 0; }
bind "Ctrl s" { SwitchToMode "Normal"; }
bind "Ctrl c" "Esc" { ScrollToBottom; SwitchToMode "Normal"; }
bind "j" "Down" { ScrollDown; }
bind "k" "Up" { ScrollUp; }
bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; }
bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; }
bind "d" { HalfPageScrollDown; }
bind "u" { HalfPageScrollUp; }
bind "n" { Search "down"; }
bind "p" { Search "up"; }
bind "c" { SearchToggleOption "CaseSensitivity"; }
bind "w" { SearchToggleOption "Wrap"; }
bind "o" { SearchToggleOption "WholeWord"; }
}
entersearch {
bind "Ctrl c" "Esc" { SwitchToMode "Scroll"; }
bind "Enter" { SwitchToMode "Search"; }
}
scroll {
bind "Esc" { SwitchToMode "Normal"; }
bind "e" { EditScrollback; SwitchToMode "Normal"; }
bind "/" { SwitchToMode "EnterSearch"; SearchInput 0; }
bind "Ctrl c" { ScrollToBottom; SwitchToMode "Normal"; }
bind "j" "Down" { ScrollDown; }
bind "k" "Up" { ScrollUp; }
bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; }
bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; }
bind "d" { HalfPageScrollDown; }
bind "u" { HalfPageScrollUp; }
}
session {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
bind "d" { Detach; }
bind "S" {
LaunchOrFocusPlugin "session-manager" {
floating true
move_to_focused_tab true
};
SwitchToMode "Normal"
}
bind "c" {
LaunchOrFocusPlugin "configuration" {
floating true
move_to_focused_tab true
};
SwitchToMode "Normal"
}
}
renametab {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
// bind "Esc" { UndoRenameTab; SwitchToMode "Tab"; }
}
renamepane {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
// bind "Esc" { UndoRenamePane; SwitchToMode "Pane"; }
}
// Unused modes is only given escape keys to return to normal mode.
pane {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
}
move {
bind "Ctrl c" "Esc" { SwitchToMode "Normal"; }
}
}
'';
'';
home.file.".config/zellij/layouts/default.kdl".text = /*kdl*/ ''
layout {
@ -220,7 +224,7 @@ in
}
pane size=1 borderless=true {
plugin location="file:${plugins.zstatus}" {
plugin location="file:${plugins.zj-status}" {
format_left "{mode}#[fg=black,bg=blue,bold]{session} #[fg=blue,bg=#181825]{tabs}"
format_right "#[fg=#181825,bg=#b1bbfa]{datetime}"
format_space "#[bg=#181825]"

View file

@ -89,6 +89,11 @@
# Also, there is resurrections features that zellij offers.
# So desktop user can just resurrect the session if they want to.
autoAttach = lib.mkEnableOption "zellij autoAttach";
mod = lib.mkOption {
type = lib.types.str;
default = "Ctrl a";
description = "Mod key to use for zellij to enter tmux mode and exits locked mode.";
};
};
foot.enable = lib.mkEnableOption "foot";
};