2023-09-02 15:33:36 +02:00
{ config , pkgs , . . . }:
2023-11-23 11:09:32 +01:00
let
2025-01-06 16:05:58 +01:00
# https://nixos.wiki/wiki/Zsh
2023-11-23 11:09:32 +01:00
zsh-config = {
enable = true ;
2025-01-06 16:05:58 +01:00
autosuggestion . enable = true ;
syntaxHighlighting . enable = true ;
2023-11-23 11:09:32 +01:00
shellAliases = {
#ll = "ls -l";
#update = "sudo nixos-rebuild switch";
} ;
2025-01-06 16:05:58 +01:00
# 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 = [ " h i s t o r y * " ] ;
2023-11-23 11:09:32 +01:00
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 = " a g n o s t e r " ;
} ;
} ;
in
2023-09-02 15:33:36 +02:00
{
2023-09-06 14:02:19 +02:00
# https://nixos.wiki/wiki/Command_Shell
2025-01-06 16:05:58 +01:00
# 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.
2023-09-06 14:02:19 +02:00
programs . zsh . enable = true ;
users . defaultUserShell = pkgs . zsh ;
2023-09-05 17:56:38 +02:00
# Inside the following Home Manager configuration block,
# `config` refers to Home Manager configuration.
home-manager . users . yoda = { osConfig , config , pkgs , . . . }: {
2023-11-23 11:09:32 +01:00
programs . zsh = zsh-config // {
2023-09-05 17:56:38 +02:00
# nix-repl: config.home-manager.users.yoda.programs.zsh.history.path
2023-11-23 11:09:32 +01:00
# -> ~/.local/share/.histfile
history . path = " ${ config . xdg . dataHome } / . h i s t f i l e " ;
} ;
} ;
home-manager . users . root = { osConfig , config , pkgs , . . . }: {
programs . zsh = zsh-config // {
2023-09-05 17:56:38 +02:00
history . path = " ${ config . xdg . dataHome } / . h i s t f i l e " ;
2023-09-02 15:33:36 +02:00
} ;
} ;
}