From 97be9c3dbfd892d97d9a648e0cb1a2d708bb72a0 Mon Sep 17 00:00:00 2001 From: js0ny Date: Sun, 2 Nov 2025 23:59:10 +0000 Subject: [PATCH] zsh: vanilla --- nixcfgs/users/js0ny/config.nix | 2 - nixcfgs/users/js0ny/programs/shell/zsh.nix | 85 +++++++++++++++++----- 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/nixcfgs/users/js0ny/config.nix b/nixcfgs/users/js0ny/config.nix index 8029744..d47ec71 100644 --- a/nixcfgs/users/js0ny/config.nix +++ b/nixcfgs/users/js0ny/config.nix @@ -5,6 +5,4 @@ defaultTerminalRunner = "alacritty"; iconTheme = "Papirus"; }; - currentHost = { - }; } diff --git a/nixcfgs/users/js0ny/programs/shell/zsh.nix b/nixcfgs/users/js0ny/programs/shell/zsh.nix index 291de86..4aa0431 100644 --- a/nixcfgs/users/js0ny/programs/shell/zsh.nix +++ b/nixcfgs/users/js0ny/programs/shell/zsh.nix @@ -16,13 +16,20 @@ in { historySubstringSearch.enable = true; enableCompletion = true; dotDir = "${config.xdg.configHome}/zsh"; - shellAliases = aliases; + # shellAliases = aliases; defaultKeymap = "emacs"; + zsh-abbr = { + enable = true; + abbreviations = aliases; + }; syntaxHighlighting = { enable = true; patterns = { "rm -rf *" = "fg=blue,bold,bg=red"; }; + styles = { + path = "fg=cyan"; + }; highlighters = [ "main" "pattern" @@ -31,23 +38,67 @@ in { ]; }; initContent = '' - # # Emacs Hybrid - # bindkey '^A' beginning-of-line - # bindkey '^E' end-of-line - # bindkey '^F' forward-char - # bindkey '^B' backward-char - # bindkey '^P' up-line-or-history - # bindkey '^N' down-line-or-history - # # bindkey '^R' history-incremental-search-backward # Use fzf - # bindkey '^K' kill-line - # - # bindkey -M viins '^?' backward-delete-char - # bindkey -M viins '^H' backward-kill-word - zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' 'r:|=*' + # Options + # ========== - # fzf-tab 模糊匹配 - zstyle ':fzf-tab:*' use-fzf-default-bindings yes - source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh + # ! This breaks the nixos-rebuild --flake .#something + # setopt INTERACTIVE_COMMENTS # Allow comments in interactive mode + + # Globbing + setopt EXTENDED_GLOB # Extended globbing + setopt GLOB_DOTS # Include dotfiles in globbing + + # Error correction + setopt CORRECT # Suggest corrections for commands + setopt CORRECT_ALL # Suggest corrections for arguments + + # edit command line + autoload -Uz edit-command-line + zle -N edit-command-line + + ### completion + ### ================= + + # use tab to select + zstyle ':completion:*' menu select + + # substring matching + zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + + # use cache + zstyle ':completion:*' use-cache on + zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/.zcompcache" + + # Colours in completion + zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS} + + # Complete . and .. special directories + zstyle ':completion:*' special-dirs true + + # Key bindings (Emacs with modern enhancement) + # =============================================== + + bindkey '^H' backward-kill-word # Ctrl-Backspace + bindkey '^[^?' backward-kill-line # Alt-Backspace + + bindkey '^[[1;5D' backward-word # Ctrl-Left + bindkey '^[[1;5C' forward-word # Ctrl-Right + + bindkey '^[[1;3D' beginning-of-line # Alt-Left + bindkey '^[[1;3C' end-of-line # Alt-Right + + + bindkey '^[[H' beginning-of-line # Home + bindkey '^[[F' end-of-line # End + + + bindkey '^[[3~' delete-char # Delete + bindkey '^[[3;5~' kill-word # Ctrl-Delete + bindkey '^[[3;3~' kill-line # Alt-Delete + + # Misc + # ======== + # source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh ''; }; }