Configuration applied to both tuxlibre and minime.
| Package | Purpose |
|---|---|
| zsh | Z Shell |
| zsh-common | Architecture-independent zsh files |
| zsh-autosuggestions | Fish-like autosuggestions based on history |
| zsh-syntax-highlighting | Fish-like syntax highlighting at the prompt |
Install command:
apt install zsh zsh-autosuggestions zsh-syntax-highlighting
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
Suppresses the zsh new-user wizard for users who don't have a ~/.zshrc:
zsh-newuser-install() { :; }
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 %# "
/etc/zsh/zshenv and /etc/zsh/zshrc are dpkg conffiles — on package upgrade, dpkg will prompt before overwriting local changes./etc/zsh/zshenv.local is not owned by any package and will never be touched by upgrades. This is the safe place for local overrides.~/.zshrc is needed — the system-wide config handles everything and the wizard is suppressed.