diff --git a/hosts/yodaGaming/configuration.nix b/hosts/yodaGaming/configuration.nix index 0bcdafc..c08a4ea 100644 --- a/hosts/yodaGaming/configuration.nix +++ b/hosts/yodaGaming/configuration.nix @@ -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 diff --git a/hosts/yodaHedgehog/configuration.nix b/hosts/yodaHedgehog/configuration.nix index 8e4689f..e61d860 100644 --- a/hosts/yodaHedgehog/configuration.nix +++ b/hosts/yodaHedgehog/configuration.nix @@ -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 diff --git a/hosts/yodaNas/configuration.nix b/hosts/yodaNas/configuration.nix index 6eb7482..596cfb5 100644 --- a/hosts/yodaNas/configuration.nix +++ b/hosts/yodaNas/configuration.nix @@ -13,7 +13,6 @@ ../../modules/ssh-fde-unlock.nix #../../modules/git.nix - ../../modules/zsh.nix #../../modules/ssh-client.nix ../../modules/ssh-server.nix diff --git a/hosts/yodaTab/configuration.nix b/hosts/yodaTab/configuration.nix index 1e08598..7826efe 100644 --- a/hosts/yodaTab/configuration.nix +++ b/hosts/yodaTab/configuration.nix @@ -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 diff --git a/hosts/yodaTux/configuration.nix b/hosts/yodaTux/configuration.nix index 5a9f227..eca2f9d 100644 --- a/hosts/yodaTux/configuration.nix +++ b/hosts/yodaTux/configuration.nix @@ -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 diff --git a/hosts/yodaYoga/configuration.nix b/hosts/yodaYoga/configuration.nix index 8e6475d..7c01978 100644 --- a/hosts/yodaYoga/configuration.nix +++ b/hosts/yodaYoga/configuration.nix @@ -12,7 +12,6 @@ ../../modules/headless.nix ../../modules/ssh-fde-unlock.nix - ../../modules/zsh.nix ../../modules/ssh-server.nix ../../modules/docker.nix diff --git a/modules/base.nix b/modules/base.nix index 042fbf9..a7152d8 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -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 diff --git a/modules/bash.nix b/modules/bash.nix new file mode 100644 index 0000000..e4651a4 --- /dev/null +++ b/modules/bash.nix @@ -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; + }; +} diff --git a/modules/fzf.nix b/modules/fzf.nix new file mode 100644 index 0000000..80a3a8e --- /dev/null +++ b/modules/fzf.nix @@ -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 + ]; + }; +} diff --git a/modules/zsh.nix b/modules/zsh.nix index aab62c3..dec1f1e 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -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;