From 8d4cbf6a2f4261ce89b4fd0b8fbb49c5d9305ee6 Mon Sep 17 00:00:00 2001 From: shelken Date: Thu, 24 Oct 2024 21:42:27 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20zellij=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- home/apps/zellij/config.kdl | 11 ---------- home/apps/zellij/default.nix | 41 +++++++++++++++++++++++++++++++++-- home/apps/zellij/keybinds.kdl | 14 ++++++++++++ 3 files changed, 53 insertions(+), 13 deletions(-) delete mode 100644 home/apps/zellij/config.kdl create mode 100644 home/apps/zellij/keybinds.kdl diff --git a/home/apps/zellij/config.kdl b/home/apps/zellij/config.kdl deleted file mode 100644 index 8744a60..0000000 --- a/home/apps/zellij/config.kdl +++ /dev/null @@ -1,11 +0,0 @@ -// theme "catppuccin-macchiato" - -session_serialization true - -keybinds { - normal { - unbind "Ctrl q" "Ctrl s" // for vim - bind "Ctrl f" { SwitchToMode "Scroll"; } - bind "Ctrl x" { Quit; } - } -} diff --git a/home/apps/zellij/default.nix b/home/apps/zellij/default.nix index 518ff3d..3ca88c2 100644 --- a/home/apps/zellij/default.nix +++ b/home/apps/zellij/default.nix @@ -1,11 +1,28 @@ { myvars, lib, + pkgs, ... }: let theme = "catppuccin-${lib.strings.toLower myvars.catppuccin_flavor}"; - origin_file = builtins.readFile ./config.kdl; + # origin_file = builtins.readFile ./config.kdl; + keybinds-config = builtins.readFile ./keybinds.kdl; inherit (lib) concatStrings; + zellij-forgot = pkgs.stdenv.mkDerivation rec { + pname = "zellij-forgot"; + version = "0.4.0"; + + src = builtins.fetchurl { + url = "https://github.com/karimould/zellij-forgot/releases/download/${version}/zellij_forgot.wasm"; + sha256 = "sha256:1hzdvyswi6gh4ngxnplay69w1n8wlk17yflfpwfhv6mdn0gcmlsr"; + }; + phases = ["installPhase"]; + + installPhase = '' + mkdir -p $out/bin + cp $src $out/bin/zellij_forgot.wasm + ''; + }; in { programs.zellij = { enable = true; @@ -21,8 +38,28 @@ in { '' // 主题配色 theme "${theme}" + + session_serialization true + simplified_ui false + '' + '' + //键盘绑定 + keybinds { + ${keybinds-config} + + // 参考:https://github.com/nixypanda/dotfiles/blob/f5d4bb5a1efd006f1db3e29965a12dea09f10356/modules/zellij/default.nix#L56C11-L63C12 + // 插件:命令提示 + shared_except "locked" { + bind "Ctrl y" { + LaunchOrFocusPlugin "file:${zellij-forgot}/bin/zellij_forgot.wasm" { + "LOAD_ZELLIJ_BINDINGS" "true" + floating true + } + } + } + } '' - origin_file + # origin_file ]; }; } diff --git a/home/apps/zellij/keybinds.kdl b/home/apps/zellij/keybinds.kdl new file mode 100644 index 0000000..d6abb55 --- /dev/null +++ b/home/apps/zellij/keybinds.kdl @@ -0,0 +1,14 @@ +// theme "catppuccin-macchiato" + +// session_serialization true + +// keybinds { + normal { + // bind "Ctrl x" { SwitchToMode "Normal"; } + unbind "Ctrl q" "Ctrl s" "Ctrl o" "Ctrl h"// for vim + bind "Ctrl f" { SwitchToMode "Scroll"; } + bind "Ctrl x" { Quit; } + bind "Alt o" { SwitchToMode "Session"; } + bind "Alt h" { SwitchToMode "Move"; } + } +// }