zsh and bash config

This commit is contained in:
Daniel Langbein 2025-01-06 16:05:58 +01:00
parent acc4535638
commit 7de5d49b7b
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
10 changed files with 99 additions and 12 deletions

View File

@ -11,7 +11,6 @@
../../modules/power-management.nix
../../modules/ntfs.nix
#../../modules/ssh-fde-unlock.nix
../../modules/zsh.nix
../../modules/nitrokey-gpg-smartcard.nix
../../modules/ssh-client.nix
../../modules/ssh-server.nix

View File

@ -13,7 +13,6 @@
../../modules/ssh-fde-unlock.nix
#../../modules/git.nix
../../modules/zsh.nix
#../../modules/ssh-client.nix
./ssh-client-root.nix
../../modules/ssh-server.nix

View File

@ -13,7 +13,6 @@
../../modules/ssh-fde-unlock.nix
#../../modules/git.nix
../../modules/zsh.nix
#../../modules/ssh-client.nix
../../modules/ssh-server.nix

View File

@ -13,7 +13,6 @@
../../modules/usb-mtp-ptp.nix
../../modules/ntfs.nix
../../modules/git.nix
../../modules/zsh.nix
../../modules/nitrokey-gpg-smartcard.nix
../../modules/ssh-client.nix
../../modules/ssh-server.nix

View File

@ -19,7 +19,6 @@
../../modules/tuxedo-rs.nix
../../modules/ntfs.nix
../../modules/git.nix
../../modules/zsh.nix
../../modules/nitrokey-gpg-smartcard.nix
../../modules/ssh-client.nix
../../modules/ssh-server.nix

View File

@ -12,7 +12,6 @@
../../modules/headless.nix
../../modules/ssh-fde-unlock.nix
../../modules/zsh.nix
../../modules/ssh-server.nix
../../modules/docker.nix

View File

@ -1,10 +1,17 @@
{ config, pkgs, ... }:
{
imports = [
# Shell settings
#.
./bash.nix # bash settings.
./zsh.nix # zsh as default shell for yoda and root.
./fzf.nix # Fuzzy command history and file search.
# DNS settings.
#
# TODO add nix option
./dns.nix
#./dns-unencrypted.nix
./dns.nix # Encrypted DNS queries to custom name servers.
#./dns-unencrypted.nix # Custom name servers.
# Nix garbage collection.
./nix-gc.nix

27
modules/bash.nix Normal file
View File

@ -0,0 +1,27 @@
{ config, pkgs, ... }:
let
bash-config = {
enable = true;
enableCompletion = true;
historySize = 1000;
historyControl = [
"erasedups"
"ignoredups"
"ignorespace"
];
};
in
{
# Bash is always enabled, there is no way to disable it ^^
#programs.bash.enable = true;
# Required by home-manager programs.bash.enableCompletion
environment.pathsToLink = [ "/share/bash-completion" ];
home-manager.users.yoda = { osConfig, config, pkgs, ... }: {
programs.bash = bash-config;
};
home-manager.users.root = { osConfig, config, pkgs, ... }: {
programs.bash = bash-config;
};
}

37
modules/fzf.nix Normal file
View File

@ -0,0 +1,37 @@
{ config, pkgs, ... }:
let
# Fuzzy shell history and file search.
#
# Use fzf to search your command history (with STRG + r) and do file searches (with STRG + t).
#
# Resources:
# https://martinheinz.dev/blog/110
# https://fryboyter.de/fuzzy-finder-fuer-die-zsh/
# https://fryboyter.de/suche-mit-fzf-beschleunigen/
#
fzf-config = {
enable = true;
# Replace the default command `find` with faster `fd`.
# Why `fd` is better than `ripgrep` in this case: https://www.reddit.com/r/linux4noobs/comments/egb644/fzf_newcomer_fd_or_ripgrep/
defaultCommand = "fd --type f";
};
in
{
home-manager.users.yoda = { osConfig, config, pkgs, ... }: {
programs.fzf = fzf-config;
};
home-manager.users.root = { osConfig, config, pkgs, ... }: {
programs.fzf = fzf-config;
};
users.users.yoda = {
packages = with pkgs; [
fd
];
};
users.users.root = {
packages = with pkgs; [
fd
];
};
}

View File

@ -1,14 +1,36 @@
{ 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";
};
history.size = 1000;
history.ignoreDups = true;
#history.ignoreAllDups = true;
# 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;
@ -25,7 +47,7 @@ let
in
{
# https://nixos.wiki/wiki/Command_Shell
# https://nixos.wiki/wiki/Zsh
# 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;