fixed inconsistent zsh behaviour

This commit is contained in:
2026-07-11 11:19:54 +01:00
parent 921edd90e3
commit 1a70f20213

View File

@@ -1,72 +1,92 @@
{ {
self, self,
inputs, inputs,
moduleWithSystem, moduleWithSystem,
... ...
}: { }: {
flake.nixosModules.zsh = moduleWithSystem ({ flake.nixosModules.zsh = moduleWithSystem ({
pkgs, pkgs,
self', self',
... ...
}: { }: {
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (final: prev: {
zsh = self'.packages.zsh; zsh = self'.packages.zsh;
}) })
]; ];
programs.zsh = { programs.zsh = {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
enableBashCompletion = true; enableBashCompletion = true;
autosuggestions.enable = true; autosuggestions.enable = true;
syntaxHighlighting.enable = true; syntaxHighlighting.enable = true;
histSize = 10000; histSize = 10000;
}; };
users.defaultUserShell = pkgs.zsh; users.defaultUserShell = pkgs.zsh;
}); });
perSystem = { perSystem = {
pkgs, pkgs,
lib, lib,
self', self',
... ...
}: { }: {
packages = { packages = {
zsh = inputs.wrappers.wrappers.zsh.wrap { zsh = inputs.wrappers.wrappers.zsh.wrap {
inherit pkgs; inherit pkgs;
runtimePkgs = [pkgs.carapace pkgs.fzf]; runtimePkgs = [pkgs.carapace pkgs.fzf];
zshAliases = { zshAliases = {
ls = "${lib.getExe pkgs.lsd} -l"; ls = "${lib.getExe pkgs.lsd} -l";
v = lib.getExe self'.packages.nvim; v = lib.getExe self'.packages.nvim;
cat = lib.getExe pkgs.bat; cat = lib.getExe pkgs.bat;
lg = lib.getExe pkgs.lazygit; lg = lib.getExe pkgs.lazygit;
devenv = lib.getExe pkgs.devenv; devenv = lib.getExe pkgs.devenv;
carapace = lib.getExe pkgs.carapace; carapace = lib.getExe pkgs.carapace;
man = "man -P \"${lib.getExe pkgs.bat} -p\""; man = "man -P \"${lib.getExe pkgs.bat} -p\"";
nsh = "nix-shell -p"; nsh = "nix-shell -p";
}; };
zshrc.content = '' zshrc.content = ''
autoload -U compinit && compinit if (( ''${+terminfo[smkx]} )) && (( ''${+terminfo[rmkx]} )); then
export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense' # optional function zle-line-init() { echoti smkx }
zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m' function zle-line-finish() { echoti rmkx }
source <(${lib.getExe pkgs.carapace} _carapace) zle -N zle-line-init
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' zle -N zle-line-finish
fi
autoload -U compinit && compinit
export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense' # optional
zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m'
source <(${lib.getExe pkgs.carapace} _carapace)
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
source <(${lib.getExe pkgs.fzf} --zsh) autoload -U select-word-style
select-word-style bash
setopt NO_CASE_GLOB autoload -U up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[OA" up-line-or-beginning-search
bindkey "^[OB" down-line-or-beginning-search
export EDITOR=nvim bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
bindkey "^[[3;5~" kill-word
bindkey "^H" backward-kill-word
eval "$(${lib.getExe pkgs.devenv} hook zsh)" source <(${lib.getExe pkgs.fzf} --zsh)
eval "$(${lib.getExe self'.packages.ohMyPosh} init zsh)"
${lib.getExe pkgs.any-nix-shell} zsh --info-right | source /dev/stdin setopt NO_CASE_GLOB
'';
}; export EDITOR=nvim
ohMyPosh = inputs.wrappers.wrappers.oh-my-posh.wrap {
inherit pkgs; eval "$(${lib.getExe pkgs.devenv} hook zsh)"
configFile = ./config.toml; eval "$(${lib.getExe self'.packages.ohMyPosh} init zsh)"
};
}; ${lib.getExe pkgs.any-nix-shell} zsh --info-right | source /dev/stdin
}; '';
};
ohMyPosh = inputs.wrappers.wrappers.oh-my-posh.wrap {
inherit pkgs;
configFile = ./config.toml;
};
};
};
} }