Zsh System-Wide Setup

Configuration applied to both tuxlibre and minime.

Installed Packages

PackagePurpose
zshZ Shell
zsh-commonArchitecture-independent zsh files
zsh-autosuggestionsFish-like autosuggestions based on history
zsh-syntax-highlightingFish-like syntax highlighting at the prompt

Install command:

apt install zsh zsh-autosuggestions zsh-syntax-highlighting

Modified Files

1. /etc/zsh/zshenv

Added two lines at the end to source a local override file (not managed by the package manager, survives upgrades):

# Source local overrides (not managed by package manager)
[[ -f /etc/zsh/zshenv.local ]] && source /etc/zsh/zshenv.local

2. /etc/zsh/zshenv.local (new file, not package-managed)

Suppresses the zsh new-user wizard for users who don't have a ~/.zshrc:

zsh-newuser-install() { :; }

3. /etc/zsh/zshrc (full replacement)

Complete system-wide interactive shell configuration:

# Initialize completion system
autoload -Uz compinit && compinit

ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd history completion)

# GNUstep environment
[ -f /System/Library/Makefiles/GNUstep.sh ] && source /System/Library/Makefiles/GNUstep.sh

source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# Color ls output
export CLICOLOR=1
alias ls='ls --color=auto'

# Use fish-style command history
HISTFILE=~/.zsh_history      # Location of history file
HISTSIZE=10000               # Number of lines kept in memory
SAVEHIST=10000               # Number of lines saved to file

# Options for fish-like behavior
setopt hist_ignore_dups      # Don't record duplicate lines
setopt hist_reduce_blanks    # Remove unnecessary blanks
setopt inc_append_history    # Save each command as soon as it's run
setopt share_history         # Share history across all zsh sessions
setopt extended_history      # Add timestamps to history
setopt hist_find_no_dups     # Skip duplicate entries during search

# Fish-style up-arrow history search (per command line input)
autoload -Uz up-line-or-beginning-search
autoload -Uz down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search     # Up arrow
bindkey "^[[B" down-line-or-beginning-search   # Down arrow

# Load color module
autoload -U colors && colors

# Enable prompt substitution
setopt PROMPT_SUBST

local user_color='2'
local host_color='fg'
local path_color='2'

# Git info function
function git_info() {
  if ! command -v git &>/dev/null; then
    return 1
  fi
  if ! git rev-parse --is-inside-work-tree &>/dev/null; then
    return 1
  fi
  local branch=$(git symbolic-ref --short HEAD 2>/dev/null)
  if [[ -z "$branch" ]]; then
    branch=$(git describe --tags --always 2>/dev/null)
  fi
  echo "%F{$host_color}($branch)%f"
}

PROMPT="%F{$user_color}%n%f@%F{$host_color}%m%f %F{$path_color}%~\$(git_info)%f %# "

Notes