nix-git/modules/zsh.nix

69 lines
2.2 KiB
Nix

{ config, pkgs, ... }:
let
# https://nixos.wiki/wiki/Zsh
zsh-config = {
enable = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
#ll = "ls -l";
#update = "sudo nixos-rebuild switch";
};
# Keep a detailed history to analyse it later:
# https://github.com/bamos/zsh-history-analysis/blob/master/README.md
#
# View tail of history:
# history -i -10
#
# Keep a long history (for later analysis).
history.size = 100000;
# Record datetime time of commands (for later analysis).
# Instead of just `ls`, this will store e.g. `: 1736166069:0;ls`.
history.extended = true;
# Do not record an event that was just recorded again.
history.ignoreDups = false;
# Delete an old recorded event if a new event is a duplicate.
history.ignoreAllDups = false;
# Do not record if first char is space.
history.ignoreSpace = true;
# Share between sessions.
history.share = true;
# Don't record commands if they match the ignore pattern.
history.ignorePatterns = [ "history *" ];
oh-my-zsh = {
enable = true;
plugins = [
# Provides many aliases and a few useful functions.
#"git"
# Easily prefix your current or previous commands with sudo by pressing `esc` twice.
#"sudo"
];
#theme = "robbyrussell";
theme = "agnoster";
};
};
in
{
# https://nixos.wiki/wiki/Command_Shell
# When adding a new shell, always enable the shell system-wide, even if it's already enabled in your Home Manager configuration, otherwise it won't source the necessary files.
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
# Inside the following Home Manager configuration block,
# `config` refers to Home Manager configuration.
home-manager.users.yoda = { osConfig, config, pkgs, ... }: {
programs.zsh = zsh-config // {
# nix-repl: config.home-manager.users.yoda.programs.zsh.history.path
# -> ~/.local/share/.histfile
history.path = "${config.xdg.dataHome}/.histfile";
};
};
home-manager.users.root = { osConfig, config, pkgs, ... }: {
programs.zsh = zsh-config // {
history.path = "${config.xdg.dataHome}/.histfile";
};
};
}