zsh as on the admin's workstation (asxpi/nixOS modules/shell.nix): completion, autosuggestions, syntax highlighting, the same history options, key bindings and blue prompt, without what only the workstation needs. asxpi logs in with it; deploy and root keep bash, because the app CI and scripts run commands through their login shell. The new-user wizard is off, since fresh homes have no ~/.zshrc. fastfetch prints a system summary on interactive SSH logins only, so scp, CI and `ssh host <command>` stay quiet. bat and eza come along. Tried on the rehearsal services host. Assisted-by: Claude:opus-5-5
This commit is contained in:
parent
b634e50cb0
commit
39ed5d17b7
2 changed files with 71 additions and 0 deletions
|
|
@ -28,6 +28,7 @@
|
|||
sops-nix.nixosModules.sops
|
||||
./modules/hetzner.nix
|
||||
./modules/base.nix
|
||||
./modules/shell.nix
|
||||
./modules/podman.nix
|
||||
./modules/wireguard.nix
|
||||
./modules/alert.nix
|
||||
|
|
|
|||
70
nixos/modules/shell.nix
Normal file
70
nixos/modules/shell.nix
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
# Interactive shell for the admins: zsh as on the admin's workstation
|
||||
# (asxpi/nixOS, modules/shell.nix), minus what only makes sense there.
|
||||
#
|
||||
# deploy keeps bash: the app CI runs its SSH scripts through deploy's
|
||||
# login shell, and they are bash. root keeps bash too, for scripts and
|
||||
# `ssh root@host '<command>'`.
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
autosuggestions.enable = true;
|
||||
syntaxHighlighting.enable = true;
|
||||
|
||||
histSize = 10000;
|
||||
histFile = "$HOME/.zsh_history";
|
||||
|
||||
shellAliases = {
|
||||
ls = "ls --color=auto";
|
||||
grep = "grep --color=auto";
|
||||
};
|
||||
|
||||
# Blue: [HH:MM:SS] [user@host path] $
|
||||
promptInit = ''
|
||||
PROMPT='%B%F{#0055ff}[%b%f%D{%H:%M:%S}%B%F{#0055ff}]%b%f %B%F{#0055ff}[%b%f%n@%m %B%F{#0055ff}%~]%b%f %B%F{#0055ff}$%b%f '
|
||||
'';
|
||||
|
||||
# Fresh homes have no ~/.zshrc: never offer the new-user wizard
|
||||
shellInit = ''
|
||||
zsh-newuser-install() { :; }
|
||||
'';
|
||||
|
||||
interactiveShellInit = ''
|
||||
setopt SHARE_HISTORY
|
||||
setopt HIST_IGNORE_DUPS
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
bindkey -e
|
||||
|
||||
zstyle ':completion:*' menu select
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
|
||||
zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}"
|
||||
zstyle ':completion:*' rehash true
|
||||
|
||||
bindkey "^[[H" beginning-of-line # Home
|
||||
bindkey "^[[F" end-of-line # End
|
||||
bindkey "^[[3~" delete-char # Delete
|
||||
bindkey "^[[1;5C" forward-word # Ctrl+Right
|
||||
bindkey "^[[1;5D" backward-word # Ctrl+Left
|
||||
bindkey '^R' history-incremental-search-backward
|
||||
|
||||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
|
||||
'';
|
||||
};
|
||||
|
||||
users.users.asxpi.shell = pkgs.zsh;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
fastfetch
|
||||
bat
|
||||
eza
|
||||
];
|
||||
|
||||
# System summary on interactive SSH logins only: scp, CI and
|
||||
# `ssh host <command>` stay quiet
|
||||
environment.loginShellInit = ''
|
||||
if [ -n "''${SSH_TTY:-}" ] && [ -t 1 ]; then
|
||||
${lib.getExe pkgs.fastfetch} 2>/dev/null
|
||||
fi
|
||||
'';
|
||||
}
|
||||
Loading…
Reference in a new issue