Files
nix/users/blake/dots/core/zsh/default.nix
2025-11-07 03:13:49 -06:00

148 lines
4.1 KiB
Nix

{
pkgs,
lib,
config,
...
}: let
program = "zsh";
cfg = config.dots.${program};
home_dir = config.home.homeDirectory;
#sec = sops.secrets;
in {
options.dots.${program} = {
enable = lib.mkEnableOption "enables ${program}";
};
config = lib.mkIf cfg.enable {
# export some defaults
home.sessionVariables = {
EDITOR = "nvim";
PAGER = "less";
};
programs.${program} = {
enable = true;
dotDir = ".config/zsh";
autocd = true;
enableCompletion = true;
autosuggestion = {
enable = true;
highlight = "underline";
};
history = {
size = 10000;
save = 10000;
share = true;
append = true;
extended = true;
path = "$XDG_STATE_HOME/zsh/history";
};
shellAliases = {
# --- zsh ---
cfz = "nvim ${home_dir}/.config/zsh/.zshrc";
src = "source ${home_dir}/.config/zsh/.zshrc";
# --- config editing ---
cfh = "nvim ${home_dir}/.config/hypr/hyprland.conf";
cfl = "nvim ${home_dir}/.config/lf/lfrc";
# --- navigation ---
ls = "ls --color=auto --group-directories-first";
ll = "ls -lh --color=auto --group-directories-first";
la = "ls -Alh --color=auto --group-directories-first";
".." = "cd ..";
"..." = "cd ../..";
fs = "du -h | sort -h";
ds = "du -hs";
# --- shortcuts ---
vswap = "cd ${home_dir}/.local/state/nvim/swap";
rswap = "rm ${home_dir}/.local/state/nvim/swap/*";
v = "nvim";
sv = "sudo nvim";
vim = "nvim";
# --- safety ---
cp = "cp -iv";
mv = "mv -iv";
rm = "rm -Iv";
# --- colors ---
grep = "grep --color=auto";
fgrep = "fgrep --color=auto";
egrep = "egrep --color=auto";
# --- scripts ---
motd = "sh /etc/motd";
rebuild = "sh ${home_dir}/.nix/bin/rebuild";
perms = "sudo sh ${home_dir}/.nix/bin/fix-perms";
# --- git ---
status = "git status";
add = "git add";
commit = "git commit -am";
push = "git push";
pull = "git pull";
dotfiles = "/usr/bin/git --git-dir=${home_dir}/.dotfiles --work-tree=$HOME";
dtf = "/usr/bin/git --git-dir=${home_dir}/.dotfiles --work-tree=$HOME";
sec = "sops ${home_dir}/.nix/secrets/secrets.yaml";
# --- systemd ---
stat = "sudo systemctl status";
restart = "sudo systemctl restart";
start = "sudo systemctl start";
stop = "sudo systemctl stop";
jou = "sudo journalctl -xeu";
live = "sudo journalctl -o short-iso -n 50 -fu";
# --- system ---
peace = "systemctl poweroff";
love = "systemctl reboot";
lock = "loginctl lock-session";
};
initContent = ''
# the prompt
PS1='%F{0}%K{126}%B[%n@%m]%b%k%f:%F{015}%B[%~]%b%f%F{015}%S$%s%f '
# lf changes working dir on exit
alias lf='lfcd'
lfcd () {cd "$(command lf -print-last-dir "$@")"}
'';
syntaxHighlighting = {
enable = true;
highlighters = ["main" "brackets" "pattern" "regexp" "cursor" "root"];
styles = {
"default" = "none";
"unknown-token" = "fg=red";
"reserved-word" = "fg=red";
"alias" = "fg=cyan,underline";
"suffix-alias" = "fg=cyan,underline";
"builtin" = "fg=cyan";
"function" = "fg=cyan";
"command" = "fg=cyan,bold";
"path" = "fg=cyan,underline";
"precommand" = "fg=cyan,underline";
"commandseparator" = "fg=white";
"globbing" = "fg=white";
"history-expansion" = "fg=white";
"hashed-command" = "fg=magenta";
"single-hyphen-option" = "fg=blue";
"double-hyphen-option" = "fg=blue";
"back-quoted-argument" = "fg=yellow";
"single-quoted-argument" = "fg=white";
"double-quoted-argument" = "fg=white";
"dollar-double-quoted-argument" = "fg=blue";
"back-double-quoted-argument" = "fg=blue";
};
};
};
};
}