1+ { config , pkgs , ... } :
2+
3+ {
4+ programs . zsh = {
5+ enable = true ;
6+ enableCompletion = true ;
7+ syntaxHighlighting . enable = true ;
8+
9+ dotDir = "${ config . xdg . configHome } /zsh" ;
10+
11+ plugins = [
12+ {
13+ name = "zsh-autosuggestions" ;
14+ src = pkgs . zsh-autosuggestions ;
15+ }
16+ {
17+ name = "zsh-syntax-highlighting" ;
18+ src = pkgs . zsh-syntax-highlighting ;
19+ }
20+ {
21+ name = "fzf-tab" ;
22+ src = pkgs . zsh-fzf-tab ;
23+ }
24+ ] ;
25+
26+ initContent = ''
27+ export LANG=zh_CN.UTF-8
28+ export EDITOR=nano
29+
30+ # === History ===
31+ HISTFILE=$XDG_STATE_HOME/zsh/history
32+ HISTSIZE=10000
33+ SAVEHIST=10000
34+ setopt HIST_IGNORE_DUPS HIST_IGNORE_SPACE SHARE_HISTORY INC_APPEND_HISTORY
35+
36+ # === Tools ===
37+ if command -v atuin >/dev/null 2>&1; then
38+ eval "$(atuin init zsh)"
39+ fi
40+ if command -v zoxide >/dev/null 2>&1; then
41+ eval "$(zoxide init zsh)"
42+ fi
43+ if command -v starship >/dev/null 2>&1; then
44+ eval "$(starship init zsh)"
45+ fi
46+
47+ # === Colors and Aliases ===
48+ autoload -U colors && colors
49+ alias ls='eza --icons=auto --group-directories-first'
50+ alias ll='eza -lh --icons=auto --group-directories-first'
51+ alias la='eza -lha --icons=auto --group-directories-first'
52+
53+ alias grep='grep --color=auto'
54+ alias fgrep='fgrep --color=auto'
55+ alias egrep='egrep --color=auto'
56+ alias ..='cd ..'
57+ alias ...='cd ../..'
58+
59+ # === Completion ===
60+ autoload -Uz compinit
61+ mkdir -p ~/.cache/zsh
62+ compinit -d ~/.cache/zsh/zcompdump
63+ setopt CORRECT
64+
65+ # === Load plugins manually ===
66+ if [[ -o interactive ]]; then
67+ source ${ pkgs . zsh-autosuggestions } /share/zsh-autosuggestions/zsh-autosuggestions.zsh
68+ source ${ pkgs . zsh-syntax-highlighting } /share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
69+ source ${ pkgs . zsh-fzf-tab } /share/fzf-tab/fzf-tab.plugin.zsh
70+
71+ ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
72+ ZSH_AUTOSUGGEST_STRATEGY=(history completion)
73+
74+ bindkey -e
75+ bindkey "$(tput kcuf1)" autosuggest-accept
76+ fi
77+
78+ # === Prompt ===
79+ if ! command -v starship >/dev/null 2>&1; then
80+ PROMPT='%F{green}%n@%m%f:%F{blue}%~%f %# '
81+ RPROMPT='%F{yellow}[%D{%H:%M}]%f'
82+ fi
83+ '' ;
84+ } ;
85+ }
0 commit comments