Add configuration for zsh

- Add ~/.zshrc
  + Configure on how the `history` works
  + Enable nicer `cd` and globbing behavior
  + Enable tab completion, and make them feel nicer
  + Enable VI mode and add some VI-like key bindings
- Add ~/.zlogout clearing the screen
- Add ~/.config/zsh/.zshrc and make it dispatch to ~/.zshrc
  to make `zsh` use the same configuration even on more
  recent Debian/Ubuntu machines that do not look for
  ~/.zshrc any more
- Ensure ~/.local/state/zsh/ exists
This commit is contained in:
Alexander Hess 2026-06-11 18:28:02 +02:00
commit 3abcdabf31
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
11 changed files with 209 additions and 0 deletions

View file

@ -12,9 +12,19 @@ forget() { # the current history and restore $HISTFILE from disk
if [ -n "$BASH_VERSION" ]; then
history -c
history -r
elif [ -n "$ZSH_VERSION" ]; then
_histsize=$HISTSIZE
HISTSIZE=0 # because shrinking the list to 0 discards all entries
HISTSIZE=$_histsize
unset _histsize
fc -R "$HISTFILE"
fi
}
if [ -n "$ZSH_VERSION" ]; then
alias forget=' forget' # Leading space => The invocation itself is forgotten because of `setopt HIST_IGNORE_SPACE`
fi
alias path='echo $PATH | tr ":" "\n"'

8
.config/zsh/.zlogout Normal file
View file

@ -0,0 +1,8 @@
#!/bin/zsh
# Failsafe: Dispatch to the real `zsh` logout file in ~/
#
# See ~/.config/zsh/.zshrc for the details
[ -f "$HOME/.zlogout" ] && . "$HOME/.zlogout"

11
.config/zsh/.zshenv Normal file
View file

@ -0,0 +1,11 @@
#!/bin/zsh
# Failsafe: Dispatch to the real `zsh` env file in ~/
#
# See ~/.config/zsh/.zshrc for the details
#
# Without this, a set `$ZDOTDIR` would silently skip ~/.zshenv
# and lose `skip_global_compinit=1`
[ -f "$HOME/.zshenv" ] && . "$HOME/.zshenv"

12
.config/zsh/.zshrc Normal file
View file

@ -0,0 +1,12 @@
#!/bin/zsh
# Failsafe: Dispatch to the real `zsh` config file in ~/
#
# `zsh` itself only reads `$ZDOTDIR`, which defaults to ~/,
# and never looks into ~/.config/zsh on its own
# => This file is dead code unless something sets `$ZDOTDIR`
# to this folder (e.g., a future Debian default;
# see Debian bug #1036290 for such a proposal)
[ -f "$HOME/.zshrc" ] && . "$HOME/.zshrc"

8
.config/zsh/README.md Normal file
View file

@ -0,0 +1,8 @@
# `zsh`-related Configurations
This folder is NOT read by `zsh` by default:
`zsh` only reads `$ZDOTDIR`, which defaults to ~/.
The files here are failsafes:
Should some machine or future distribution set `$ZDOTDIR` to this folder,
they dispatch back to the real config files in ~/.