nixOS/modules/shell.nix
Sergei Poljanski f4a352aeaa
shell: drop the nrs alias
It ran git add -A, so a rebuild swept every unrelated change in
/etc/nixos into one "Update: <date>" commit and pushed it. Rebuild
and commit separately instead.

Assisted-by: Claude:opus-5-5
2026-10-20 12:10:05 +04:00

89 lines
2.8 KiB
Nix

# Zsh and shell configuration
{ config, pkgs, lib, ... }:
{
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestions.enable = true;
syntaxHighlighting.enable = true;
# History settings
histSize = 10000;
histFile = "$HOME/.zsh_history";
# Shell aliases
shellAliases = {
ls = "ls --color=auto";
grep = "grep --color=auto";
};
# Prompt configuration
promptInit = ''
# Blue colored prompt: [HH:MM:SS] [user@host path] $
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 '
'';
interactiveShellInit = ''
# Prevent zsh-newuser-install wizard (creates marker file if missing)
[[ ! -f ~/.zshrc ]] && touch ~/.zshrc
# History options
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
bindkey -e
# Enhanced completion settings
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
# Key bindings for navigation
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
# Autosuggestions color
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
# Environment variables
export GOPATH=$HOME/.go
export PATH=$PATH:$GOPATH/bin
export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/.opencode/bin:$PATH
export PATH=$HOME/.cache/npm/global/bin:$PATH
# Google Cloud SDK (if exists)
if [ -f "$HOME/Code/gke/google-cloud-sdk/path.zsh.inc" ]; then
source "$HOME/Code/gke/google-cloud-sdk/path.zsh.inc"
fi
if [ -f "$HOME/Code/gke/google-cloud-sdk/completion.zsh.inc" ]; then
source "$HOME/Code/gke/google-cloud-sdk/completion.zsh.inc"
fi
# NVM (if you need it - consider using nixpkgs nodejs instead)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion"
'';
};
# Second Claude Code profile for the work (Teams) account. A wrapper, not a
# zsh alias, so it also works in bash (nix develop, nix-shell, scripts).
# claude comes from the native installer in ~/.local/bin.
environment.systemPackages = [
(pkgs.writeShellScriptBin "claude-work" ''
PATH="$PATH:$HOME/.local/bin" CLAUDE_CONFIG_DIR="$HOME/.claude-work" exec claude "$@"
'')
];
# Set GPG_TTY for all users
environment.shellInit = ''
export GPG_TTY=$(tty)
'';
}