# Autoload add-zsh-hook to add/remove zsh hook functions easily.
autoload -Uz add-zsh-hook
-# Load zmv (zsh move) which is powerful to rename files.
+# Load zmv (zsh move) which is a powerful file renamer.
autoload -Uz zmv
setopt histignoredups
# Vim like completions of previous executed commands (also enter Vi-mode). If
# called at the beginning it just recalls old commands (like cursor up), if
-# called after typing something, only lines starting with the typed are
-# returned. Very useful to get old commands quickly. Thanks to Mikachu in #zsh
-# on Freenode (2010-01-17 12:47 CET) for the information how to a use function
-# with bindkey.
+# called after typing something, only lines starting with the typed text are
+# returned. Very useful to get old commands quickly - in addition to the
+# history commands (!..). Thanks to Mikachu in #zsh on Freenode (2010-01-17
+# 12:47 CET) for the information how to a use function with bindkey.
zle -N my-vi-history-beginning-search-backward
my-vi-history-beginning-search-backward() {
local not_at_beginning_of_line
zmodload zsh/datetime
# Some shortcuts for colors. The %{...%} tells zsh that the data in between
-# doesn't need any space, necessary for correct prompt draw.
+# doesn't need any space, necessary for correct prompt drawing.
local red="%{${fg[red]}%}"
local blue="%{${fg[blue]}%}"
local green="%{${fg[green]}%}"
zstyle ':vcs_info:*' unstagedstr '¹'
zstyle ':vcs_info:*' stagedstr '²'
- # Default to running vcs_info. If possible we prevent running it later for
+ # Default to run vcs_info. If possible we prevent running it later for
# speed reasons. If set to a non empty value vcs_info is run.
FORCE_RUN_VCS_INFO=1
fi
# Set the prompt. A two line prompt is used. On the top left the current
-# working directory is displayed, on the right vcs_info (if available). On the
-# bottom left current user name and host is shown, the exit code of the last
-# command if it wasn't 0, the number of running jobs if not 0.
+# working directory is displayed, on the right vcs_info (if available) and the
+# current time in hex. On the bottom left current user name and host is shown,
+# the exit code of the last command if it wasn't 0, the number of running jobs
+# if not 0.
#
# The prompt is in green and blue to make easily detectable, the error exit
# code in red and bold and the job count in yellow.
#
# Thanks to Adam's prompt for the basic idea of this prompt.
-#
-# The current time is display in hex in the right prompt.
prompt_precmd() {
# Regex to remove elements which take no space. Used to calculate the
# width of the top prompt. Thanks to Bart's and Adam's prompt code in
# COMPLETION SETTINGS
-# Load the complist module which provides additions to completion lists
-# (coloring, scrollable).
+# Load the complist module which provides additional features to completion
+# lists (coloring, scrolling).
zmodload zsh/complist
# Use new completion system, store dumpfile in ~/.zsh/cache to prevent
# cluttering of ~/. $fpath must be set before calling this. Thanks to Adlai in
# problem.
autoload -Uz compinit && compinit -d ~/.zsh/cache/zcompdump
-# Use cache to speed up completions.
+# Use cache to speed up some slow completions (dpkg, perl modules, etc.).
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
# Complete arguments and fix spelling mistakes when possible.
zstyle ':completion:*' completer _complete _match _correct _approximate
-# Make sure the list of possible completions is displayed after pressing <TAB>
-# the first time.
+# If there are multiple matches after pressing <Tab> always display them
+# immediately without requiring another <Tab>. a<Tab> lists aaa, aab, aac as
+# possible completions if the directory contains aaa, aab, aac, bbb.
setopt nolistambiguous
# Allow completions in the middle of a text, i.e. "/usr/bin/<TAB>whatever"
# completes like "/usr/bin/<TAB>". Useful when adding new options to commands.
# typing in lowercase most of the time and completion fixes the case.
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}'
-# Use ls like colors for completions.
+# Use ls-like colors for completions.
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# Make completion lists scrollable so "do you wish to see all n possibilities"
-# is no longer displayed.
+# is no longer displayed. Display current position in percent (%p).
zstyle ':completion:*' list-prompt '%p'
-# Display group name (like 'external command', 'alias', etc.) when there are
-# multiple matches in bold.
+# Display group name (%d) (like 'external command', 'alias', etc.), in bold.
zstyle ':completion:*' format ' %B%d%b:'
# Display different types of matches separately.
zstyle ':completion:*' group-name ''
zstyle ':completion:*:*:-command-:*' ignored-patterns './config.*'
# Don't complete unwanted files with Vim. Thanks to Nomexous in #zsh on
-# Freenode (2010-06-06 04:54 CEST). See below to complete them.
+# Freenode (2010-06-06 04:54 CEST). See below for a way to complete them.
zstyle ':completion:*:*:vim:*:all-files' ignored-patterns '*.aux' '*.log' \
'*.pdf' '*.class'