Files
nixos-config/home-manager/modules/zsh/zsh.nix
T
2025-11-18 00:30:24 +03:00

119 lines
3.1 KiB
Nix

{ config, pkgs, ... }:
{
home.packages = with pkgs; [ zsh-powerlevel10k fzf fd eza zoxide ];
programs.zsh = {
enable = true;
autocd = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
history = {
append = true;
ignoreAllDups = true;
ignoreDups = true;
saveNoDups = true;
};
plugins = with pkgs; [
{
file = "powerlevel10k.zsh-theme";
name = "powerlevel10k";
src = "${zsh-powerlevel10k}/share/zsh-powerlevel10k";
}
{
file = "p10k.zsh";
name = "powerlevel10k-config";
src = ./p10k.zsh;
}
];
oh-my-zsh = {
enable = true;
plugins = [
"git"
"python"
"ssh"
"eza"
"zoxide"
"fzf"
"command-not-found"
"colored-man-pages"
];
};
shellAliases = {
ll = "ls -lh";
la = "ls -la";
".." = "cd ..";
"..." = "cd ../..";
c = "clear";
addpath = "export PATH=$PATH:$1";
tree = "eza --tree";
kk = "sudo kill -9";
grepps = "ps -A | grep";
gitpa = ''f() { git add -A && git commit -m "$1" && git push; }; f'';
home-cnfg = "nvim ~/.config/home-manager/home.nix";
home-rr = "home-manager switch";
cnfg = "sudo nvim /nixos/configuration.nix";
rr = "sudo nixos-rebuild switch";
amnezia = ''
(pgrep -x ".AmneziaVPN-ser" > /dev/null 2>&1 || sudo AmneziaVPN-service > /dev/null 2>&1 &) &
AmneziaVPN > /dev/null 2>&1 &
''; # i don't know any good ways for it.
mkenv = ''
echo "use nix" > .envrc && touch default.nix && direnv allow && echo "✓ env created"'';
};
initContent = ''
zstyle ':omz:plugins:eza' 'git-status' yes
zstyle ':omz:plugins:eza' 'header' yes
zstyle ':omz:plugins:eza' 'icons' yes
ZOXIDE_CMD_OVERRIDE=cd
### --- COMPLETION TUNING -----------------------------
autoload -Uz compinit && compinit
zstyle ':completion:*' menu select
zstyle ':completion:*' list-colors ""
### --- KEYBINDINGS ----------------------------------
# bindkey -e # Emacs-style bindings
# bindkey -v # Vim-style bindings
### --- ENVIRONMENT VARS ------------------------------
export EDITOR="nvim"
export VISUAL="nvim"
export PAGER="less"
export LESS="-R"
# --- fzf configuration ---
if command -v fzf >/dev/null 2>&1; then
# Enable key bindings and auto-completion
[ -f "${pkgs.fzf}/share/fzf/key-bindings.zsh" ] && source "${pkgs.fzf}/share/fzf/key-bindings.zsh"
[ -f "${pkgs.fzf}/share/fzf/completion.zsh" ] && source "${pkgs.fzf}/share/fzf/completion.zsh"
# Example of optional fzf tuning
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
fi
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
eval "$(zoxide init zsh --cmd cd)"
'';
};
home.file.".p10k.zsh".source = ./p10k.zsh;
}