mirror of
https://codeberg.org/privacy1st/nix-git
synced 2025-01-09 04:51:20 +01:00
73 lines
2.8 KiB
Nix
73 lines
2.8 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.
|
|
# This implies INC_APPEND_HISTORY which records commands as soon as they are entered, rather than waiting until the shell exits.
|
|
# https://zsh.sourceforge.io/Doc/Release/Options.html
|
|
history.share = true;
|
|
# Don't record commands if they match one of the given shell patterns.
|
|
# Only in zsh grouping (`(a|b)`) is available: https://thevaluable.dev/zsh-expansion-guide-example/
|
|
# TODO: Somehow HISTORY_IGNORE is missing in my zsh config. https://github.com/nix-community/home-manager/blob/613691f285dad87694c2ba1c9e6298d04736292d/modules/programs/zsh.nix#L680
|
|
history.ignorePatterns = [ "(cd|ls) (./|../)*" "pwd" "ls" "cd" ];
|
|
|
|
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"; # If in a Git directory, adds the branch to the shell promt.
|
|
};
|
|
};
|
|
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";
|
|
};
|
|
};
|
|
}
|