diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc new file mode 100644 index 0000000..571e93c --- /dev/null +++ b/.config/zsh/.zshrc @@ -0,0 +1,10 @@ +#!/bin/zsh + +# Load the real `zsh` config file in ~/ +# +# Recent Debian/Ubuntu versions look for .zshrc +# in .config/zsh and no longer in ~/ which +# is still the main location in many other distributions + + +. "$HOME/.zshrc" diff --git a/.config/zsh/README.md b/.config/zsh/README.md new file mode 100644 index 0000000..a2882a4 --- /dev/null +++ b/.config/zsh/README.md @@ -0,0 +1,3 @@ +# `zsh`-related Configurations + +This folder contains files that are sourced by `zsh`. diff --git a/.local/state/zsh/.gitkeep b/.local/state/zsh/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.profile b/.profile index 3d44a67..db89137 100644 --- a/.profile +++ b/.profile @@ -51,6 +51,10 @@ if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ]; then fi +# `zsh`-specific configurations are automatically sourced from ~/.zshrc, +# which then also ensures that this file is sourced + + # Put local executables on the `$PATH` _prepend_to_path "$HOME/.local/bin" diff --git a/.zlogout b/.zlogout new file mode 100644 index 0000000..4ec153e --- /dev/null +++ b/.zlogout @@ -0,0 +1,3 @@ +#!/bin/zsh + +. "$XDG_CONFIG_HOME/shell/logout" diff --git a/.zshrc b/.zshrc index 3a46429..81a88e8 100644 --- a/.zshrc +++ b/.zshrc @@ -3,5 +3,78 @@ # `zsh`-specific configurations +# Remove built-in aliases because we use our own, sourced via ~/.profile +unalias -a + + # Load configuration files common to all kinds of shells [ -f "$HOME/.profile" ] && . "$HOME/.profile" + + +# Ensure `zsh` is running interactively +[[ -o interactive ]] || return + + +# Make `zsh` behave like `bash` for prompts +PS1='%n@%m:%~%(!.#.$) ' + + +# Configure the `history` + +# Set these environment variables here +# to avoid conflict/overlap with `bash` + +export HISTFILE="$XDG_STATE_HOME/zsh/history" +export HISTSIZE=999999 # Number of lines kept in memory +export SAVEHIST=999999 # Number of lines kept in the `$HISTFILE` + +setopt APPEND_HISTORY # Do not overwrite the `$HISTFILE` +setopt INC_APPEND_HISTORY # Write to the `$HISTFILE` immediately +setopt HIST_REDUCE_BLANKS # Remove superfluous blanks from the `history` +setopt HIST_VERIFY # Show expanded `history` before executing + + +# Make `zsh` feel even nicer + +setopt AUTO_CD # Just type the directory to `cd` into it +setopt EXTENDED_GLOB # Advanced globbing patterns +setopt NULL_GLOB # Remove patterns with no matches +setopt CORRECT # Correct spelling of commands +setopt CHECK_JOBS # Show number of running jobs when exiting `zsh` +setopt NO_BEEP # Silence `zsh` + + +stty -ixon # Prevent Ctrl+S from freezing `zsh` + + +# Enable (tab) completions + +autoload -Uz compinit && compinit + +# Enable match highlighting and scrolling through long lists, +# and provide a different style of menu completion +zmodload zsh/complist + +# Include hidden files in tab completion +_comp_options+=(GLOB_DOTS) + +# Make selecting completions nicer with a visual menu +zstyle ':completion:*' menu select + +# Make new executables completable right away +zstyle ':completion:*' rehash true + + +# Configure key bindings + +# VI mode +bindkey -v + +# Use VI keys to navigate the completions in the menu +bindkey -M menuselect 'h' vi-backward-char +bindkey -M menuselect 'k' vi-up-line-or-history +bindkey -M menuselect 'l' vi-forward-char +bindkey -M menuselect 'j' vi-down-line-or-history + +# Enable Ctrl-R for reverse history search +bindkey "^R" history-incremental-search-backward