fix(zsh): merge init in correct order

This commit is contained in:
514fpv 2025-05-07 17:15:14 +08:00
parent eab6653747
commit f7faa86f1d
Signed by: koishi
SSH key fingerprint: SHA256:VkIdW3jUIiqecV2WNAje2fGU5lEhN0XZ58DN0NS4pv0

View file

@ -1,5 +1,6 @@
{
config,
lib,
...
}:
{
@ -31,8 +32,7 @@
};
enableCompletion = true;
initContent = ''
completionInit = ''
zstyle ':completion:*' auto-description '%d'
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' format '%S%d%s'
@ -47,39 +47,47 @@
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' substitute 1
# enable colors for prompt
autoload -U colors && colors
# shell context indicator
PARTICLE=""
if [[ -v IN_NIX_SHELL ]]; then
PARTICLE="$IN_NIX_SHELL "
elif [[ $SHLVL != 1 ]]; then
PARTICLE="nested "
fi
# set misc zsh options
setopt HIST_FIND_NO_DUPS
unsetopt extendedglob
unsetopt beep
unsetopt notify
unsetopt nomatch
# set terminal title
function precmd {
echo -ne "\e]0;$USER@$HOST <3 ''${PWD/#"$HOME"/~} $PARTICLE\a"
}
# set up history search
autoload -U history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey '^[[B' history-beginning-search-forward-end
bindkey '^[OB' history-beginning-search-forward-end
zle -N history-beginning-search-backward-end history-search-end
bindkey '^[[A' history-beginning-search-backward-end
bindkey '^[OA' history-beginning-search-backward-end
autoload -U compinit && compinit
'';
initContent = lib.mkMerge [
(lib.mkBefore ''
# enable colors for prompt
autoload -U colors && colors
# shell context indicator
PARTICLE=""
if [[ -v IN_NIX_SHELL ]]; then
PARTICLE="$IN_NIX_SHELL "
elif [[ $SHLVL != 1 ]]; then
PARTICLE="nested "
fi
'')
(''
# set misc zsh options
setopt HIST_FIND_NO_DUPS
unsetopt extendedglob
unsetopt beep
unsetopt notify
unsetopt nomatch
# set terminal title
function precmd {
echo -ne "\e]0;$USER@$HOST <3 ''${PWD/#"$HOME"/~} $PARTICLE\a"
}
# set up history search
autoload -U history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey '^[[B' history-beginning-search-forward-end
bindkey '^[OB' history-beginning-search-forward-end
zle -N history-beginning-search-backward-end history-search-end
bindkey '^[[A' history-beginning-search-backward-end
bindkey '^[OA' history-beginning-search-backward-end
'')
];
shellAliases = {
ls = "ls --color=auto";