# Filename: /etc/zsh/zshrc
# Purpose: config file for zsh (z shell)
# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2.
################################################################################
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
# Global Order: zshenv, zprofile, zshrc, zlogin
################################################################################
# USAGE
# If you are using this file as your ~/.zshrc file, please use ~/.zshrc.pre
# and ~/.zshrc.local for your own customisations. The former file is read
# before ~/.zshrc, the latter is read after it. Also, consider reading the
# refcard and the reference manual for this setup, both available from:
# <http://grml.org/zsh/>
# Contributing:
# If you want to help to improve grml's zsh setup, clone the grml-etc-core
# repository from git.grml.org:
# git clone git://git.grml.org/grml-etc-core.git
#
# Make your changes, commit them; use 'git format-patch' to create a series
# of patches and send those to the following address via 'git send-email':
# grml-etc-core@grml.org
#
# Doing so makes sure the right people get your patches for review and
# possibly inclusion.
# zsh-refcard-tag documentation:
# You may notice strange looking comments in this file.
# These are there for a purpose. grml's zsh-refcard can now be
# automatically generated from the contents of the actual configuration
# file. However, we need a little extra information on which comments
# and what lines of code to take into account (and for what purpose).
#
# Here is what they mean:
#
# List of tags (comment types) used:
# #a# Next line contains an important alias, that should
# be included in the grml-zsh-refcard.
# (placement tag: @@INSERT-aliases@@)
# #f# Next line contains the beginning of an important function.
# (placement tag: @@INSERT-functions@@)
# #v# Next line contains an important variable.
# (placement tag: @@INSERT-variables@@)
# #k# Next line contains an important keybinding.
# (placement tag: @@INSERT-keybindings@@)
# #d# Hashed directories list generation:
# start denotes the start of a list of 'hash -d'
# definitions.
# end denotes its end.
# (placement tag: @@INSERT-hasheddirs@@)
# #A# Abbreviation expansion list generation:
# start denotes the beginning of abbreviations.
# end denotes their end.
# Lines within this section that end in '#d .*' provide
# extra documentation to be included in the refcard.
# (placement tag: @@INSERT-abbrev@@)
# #m# This tag allows you to manually generate refcard entries
# for code lines that are hard/impossible to parse.
# Example:
# #m# k ESC-h Call the run-help function
# That would add a refcard entry in the keybindings table
# for 'ESC-h' with the given comment.
# So the syntax is: #m# <section> <argument> <comment>
# #o# This tag lets you insert entries to the 'other' hash.
# Generally, this should not be used. It is there for
# things that cannot be done easily in another way.
# (placement tag: @@INSERT-other-foobar@@)
#
# All of these tags (except for m and o) take two arguments, the first
# within the tag, the other after the tag:
#
# #<tag><section># <comment>
#
# Where <section> is really just a number, which are defined by the
# @secmap array on top of 'genrefcard.pl'. The reason for numbers
# instead of names is, that for the reader, the tag should not differ
# much from a regular comment. For zsh, it is a regular comment indeed.
# The numbers have got the following meanings:
# 0 -> "default"
# 1 -> "system"
# 2 -> "user"
# 3 -> "debian"
# 4 -> "search"
# 5 -> "shortcuts"
# 6 -> "services"
#
# So, the following will add an entry to the 'functions' table in the
# 'system' section, with a (hopefully) descriptive comment:
# #f1# Edit an alias via zle
# edalias() {
#
# It will then show up in the @@INSERT-aliases-system@@ replacement tag
# that can be found in 'grml-zsh-refcard.tex.in'.
# If the section number is omitted, the 'default' section is assumed.
# Furthermore, in 'grml-zsh-refcard.tex.in' @@INSERT-aliases@@ is
# exactly the same as @@INSERT-aliases-default@@. If you want a list of
# *all* aliases, for example, use @@INSERT-aliases-all@@.
# zsh profiling
# just execute 'ZSH_PROFILE_RC=1 zsh' and run 'zprof' to get the details
if [[ $ZSH_PROFILE_RC -gt 0 ]] ; then
zmodload zsh/zprof
fi
# load .zshrc.pre to give the user the chance to overwrite the defaults
[[ -r ${ZDOTDIR:-${HOME}}/.zshrc.pre ]] && source ${ZDOTDIR:-${HOME}}/.zshrc.pre
# check for version/system
# check for versions (compatibility reasons)
function is4 () {
[[ $ZSH_VERSION == <4->* ]] && return 0
return 1
}
function is41 () {
[[ $ZSH_VERSION == 4.<1->* || $ZSH_VERSION == <5->* ]] && return 0
return 1
}
function is42 () {
[[ $ZSH_VERSION == 4.<2->* || $ZSH_VERSION == <5->* ]] && return 0
return 1
}
function is425 () {
[[ $ZSH_VERSION == 4.2.<5->* || $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
return 1
}
function is43 () {
[[ $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0
return 1
}
function is433 () {
[[ $ZSH_VERSION == 4.3.<3->* || $ZSH_VERSION == 4.<4->* \
|| $ZSH_VERSION == <5->* ]] && return 0
return 1
}
function is437 () {
[[ $ZSH_VERSION == 4.3.<7->* || $ZSH_VERSION == 4.<4->* \
|| $ZSH_VERSION == <5->* ]] && return 0
return 1
}
function is439 () {
[[ $ZSH_VERSION == 4.3.<9->* || $ZSH_VERSION == 4.<4->* \
|| $ZSH_VERSION == <5->* ]] && return 0
return 1
}
#f1# Checks whether or not you're running grml
function isgrml () {
[[ -f /etc/grml_version ]] && return 0
return 1
}
#f1# Checks whether or not you're running a grml cd
function isgrmlcd () {
[[ -f /etc/grml_cd ]] && return 0
return 1
}
if isgrml ; then
#f1# Checks whether or not you're running grml-small
function isgrmlsmall () {
if [[ ${${${(f)"$(</etc/grml_version)"}%% *}##*-} == 'small' ]]; then
return 0
fi
return 1
}
else
function isgrmlsmall () { return 1 }
fi
GRML_OSTYPE=$(uname -s)
function islinux () {
[[ $GRML_OSTYPE == "Linux" ]]
}
function isdarwin () {
[[ $GRML_OSTYPE == "Darwin" ]]
}
function isfreebsd () {
[[ $GRML_OSTYPE == "FreeBSD" ]]
}
function isopenbsd () {
[[ $GRML_OSTYPE == "OpenBSD" ]]
}
function issolaris () {
[[ $GRML_OSTYPE == "SunOS" ]]
}
#f1# are we running within an utf environment?
function isutfenv () {
case "$LANG $CHARSET $LANGUAGE" in
*utf*) return 0 ;;
*UTF*) return 0 ;;
*) return 1 ;;
esac
}
# check for user, if not running as root set $SUDO to sudo
(( EUID != 0 )) && SUDO='sudo' || SUDO=''
# change directory to home on first invocation of zsh
# important for rungetty -> autologin
# Thanks go to Bart Schaefer!
isgrml && function checkhome () {
if [[ -z "$ALREADY_DID_CD_HOME" ]] ; then
export ALREADY_DID_CD_HOME=$HOME
cd
fi
}
# check for zsh v3.1.7+
if ! [[ ${ZSH_VERSION} == 3.1.<7->* \
|| ${ZSH_VERSION} == 3.<2->.<->* \
|| ${ZSH_VERSION} == <4->.<->* ]] ; then
printf '-!-\n'
printf '-!- In this configuration we try to make use of features, that only\n'
printf '-!- require version 3.1.7 of the shell; That way this setup can be\n'
printf '-!- used with a wide range of zsh versions, while using fairly\n'
printf '-!- advanced features in all supported versions.\n'
printf '-!-\n'
printf '-!- However, you are running zsh version %s.\n' "$ZSH_VERSION"
printf '-!-\n'
printf '-!- While this *may* work, it might as well fail.\n'
printf '-!- Please consider updating to at least version 3.1.7 of zsh.\n'
printf '-!-\n'
printf '-!- DO NOT EXPECT THIS TO WORK FLAWLESSLY!\n'
printf '-!- If it does today, you'\''ve been lucky.\n'
printf '-!-\n'
printf '-!- Ye been warned!\n'
printf '-!-\n'
function zstyle () { : }
fi
# autoload wrapper - use this one instead of autoload directly
# We need to define this function as early as this, because autoloading
# 'is-at-least()' needs it.
function zrcautoload () {
emulate -L zsh
setopt extended_glob
local fdir ffile
local -i ffound
ffile=$1
(( ffound = 0 ))
for fdir in ${fpath} ; do
[[ -e ${fdir}/${ffile} ]] && (( ffound = 1 ))
done
(( ffound == 0 )) && return 1
if [[ $ZSH_VERSION == 3.1.<6-> || $ZSH_VERSION == <4->* ]] ; then
autoload -U ${ffile} || return 1
else
autoload ${ffile} || return 1
fi
return 0
}
# The following is the ‘add-zsh-hook’ function from zsh upstream. It is
# included here to make the setup work with older versions of zsh (prior to
# 4.3.7) in which this function had a bug that triggers annoying errors during
# shell startup. This is exactly upstreams code from f0068edb4888a4d8fe94def,
# with just a few adjustments in coding style to make the function look more
# compact. This definition can be removed as soon as we raise the minimum
# version requirement to 4.3.7 or newer.
function add-zsh-hook () {
# Add to HOOK the given FUNCTION.
# HOOK is one of chpwd, precmd, preexec, periodic, zshaddhistory,
# zshexit, zsh_directory_name (the _functions subscript is not required).
#
# With -d, remove the function from the hook instead; delete the hook
# variable if it is empty.
#
# -D behaves like -d, but pattern characters are active in the function
# name, so any matching function will be deleted from the hook.
#
# Without -d, the FUNCTION is marked for autoload; -U is passed down to
# autoload if that is given, as are -z and -k. (This is harmless if the
# function is actually defined inline.)
emulate -L zsh
local -a hooktypes
hooktypes=(
chpwd precmd preexec periodic zshaddhistory zshexit
zsh_directory_name
)
local usage="Usage: $0 hook function\nValid hooks are:\n $hooktypes"
local opt
local -a autoopts
integer del list help
while getopts "dDhLUzk" opt; do
case $opt in
(d) del=1 ;;
(D) del=2 ;;
(h) help=1 ;;
(L) list=1 ;;
([Uzk]) autoopts+=(-$opt) ;;
(*) return 1 ;;
esac
done
shift $(( OPTIND - 1 ))
if (( list )); then
typeset -mp "(${1:-${(@j:|:)hooktypes}})_functions"
return $?
elif (( help || $# != 2 || ${hooktypes[(I)$1]} == 0 )); then
print -u$(( 2 - help )) $usage
return $(( 1 - help ))
fi
local hook="${1}_functions"
local fn="$2"
if (( del )); then
# delete, if hook is set
if (( ${(P)+hook} )); then
if (( del == 2 )); then
set -A $hook ${(P)hook:#${~fn}}
else
set -A $hook ${(P)hook:#$fn}
fi
# unset if no remaining entries --- this can give better
# performance in some cases
if (( ! ${(P)#hook} )); then
unset $hook
fi
fi
else
if (( ${(P)+hook} )); then
if (( ${${(P)hook}[(I)$fn]} == 0 )); then
set -A $hook ${(P)hook} $fn
fi
else
set -A $hook $fn
fi
autoload $autoopts -- $fn
fi
}
# Load is-at-least() for more precise version checks Note that this test will
# *always* fail, if the is-at-least function could not be marked for
# autoloading.
zrcautoload is-at-least || function is-at-least () { return 1 }
# set some important options (as early as possible)
# append history list to the history file; this is the default but we make sure
# because it's required for share_history.
setopt append_history
# import new commands from the history file also in other zsh-session
is4 && setopt share_history
# save each command's beginning timestamp and the duration to the history file
setopt extended_history
# If a new command line being added to the history list duplicates an older
# one, the older command is removed from the list
is4 && setopt histignorealldups
# remove command lines from the history list when the first character on the
# line is a space
setopt histignorespace
# if a command is issued that can't be executed as a normal command, and the
# command is the name of a directory, perform the cd command to that directory.
setopt auto_cd
# in order to use #, ~ and ^ for filename generation grep word
# *~(*.gz|*.bz|*.bz2|*.zip|*.Z) -> searches for word not in compressed files
# don't forget to quote '^', '~' and '#'!
setopt extended_glob
# display PID when suspending processes as well
setopt longlistjobs
# report the status of backgrounds jobs immediately
setopt notify
# whenever a command completion is attempted, make sure the entire command path
# is hashed first.
setopt hash_list_all
# not just at the end
setopt completeinword
# Don't send SIGHUP to background processes when the shell exits.
setopt nohup
# make cd push the old directory onto the directory stack.
setopt auto_pushd
# avoid "beep"ing
setopt nobeep
# don't push the same dir twice.
setopt pushd_ignore_dups
# * shouldn't match dotfiles. ever.
setopt noglobdots
# use zsh style word splitting
setopt noshwordsplit
# don't error out when unset parameters are used
setopt unset
# setting some default values
NOCOR=${NOCOR:-0}
NOMENU=${NOMENU:-0}
NOPRECMD=${NOPRECMD:-0}
COMMAND_NOT_FOUND=${COMMAND_NOT_FOUND:-0}
GRML_ZSH_CNF_HANDLER=${GRML_ZSH_CNF_HANDLER:-/usr/share/command-not-found/command-not-found}
GRML_DISPLAY_BATTERY=${GRML_DISPLAY_BATTERY:-${BATTERY:-0}}
GRMLSMALL_SPECIFIC=${GRMLSMALL_SPECIFIC:-1}
ZSH_NO_DEFAULT_LOCALE=${ZSH_NO_DEFAULT_LOCALE:-0}
typeset -ga ls_options
typeset -ga grep_options
# Colors on GNU ls(1)
if ls --color=auto / >/dev/null 2>&1; then
ls_options+=( --color=auto )
# Colors on FreeBSD and OSX ls(1)
elif ls -G / >/dev/null 2>&1; then
ls_options+=( -G )
fi
# Natural sorting order on GNU ls(1)
# OSX and IllumOS have a -v option that is not natural sorting
if ls --version |& grep -q 'GNU' >/dev/null 2>&1 && ls -v / >/dev/null 2>&1; then
ls_options+=( -v )
fi
# Color on GNU and FreeBSD grep(1)
if grep --color=auto -q "a" <<< "a" >/dev/null 2>&1; then
grep_options+=( --color=auto )
fi
# utility functions
# this function checks if a command exists and returns either true
# or false. This avoids using 'which' and 'whence', which will
# avoid problems with aliases for which on certain weird systems. :-)
# Usage: check_com [-c|-g] word
# -c only checks for external commands
# -g does the usual tests and also checks for global aliases
function check_com () {
emulate -L zsh
local -i comonly gatoo
comonly=0
gatoo=0
if [[ $1 == '-c' ]] ; then
comonly=1
shift 1
elif [[ $1 == '-g' ]] ; then
gatoo=1
shift 1
fi
if (( ${#argv} != 1 )) ; then
printf 'usage: check_com [-c|-g] <command>\n' >&2
return 1
fi
if (( comonly > 0 )) ; then
(( ${+commands[$1]} )) && return 0
return 1
fi
if (( ${+commands[$1]} )) \
|| (( ${+functions[$1]} )) \
|| (( ${+aliases[$1]} )) \
|| (( ${+reswords[(r)$1]} )) ; then
return 0
fi
if (( gatoo > 0 )) && (( ${+galiases[$1]} )) ; then
return 0
fi
return 1
}
# creates an alias and precedes the command with
# sudo if $EUID is not zero.
function salias () {
emulate -L zsh
local only=0 ; local multi=0
local key val
while getopts ":hao" opt; do
case $opt in
o) only=1 ;;
a) multi=1 ;;
h)
printf 'usage: salias [-hoa] <alias-expression>\n'
printf ' -h shows this help text.\n'
printf ' -a replace '\'' ; '\'' sequences with '\'' ; sudo '\''.\n'
printf ' be careful using this option.\n'
printf ' -o only sets an alias if a preceding sudo would be needed.\n'
return 0
;;
*) salias -h >&2; return 1 ;;
esac
done
shift "$((OPTIND-1))"
if (( ${#argv} > 1 )) ; then
printf 'Too many arguments %s\n' "${#argv}"
return 1
fi
key="${1%%\=*}" ; val="${1#*\=}"
if (( EUID == 0 )) && (( only == 0 )); then
alias -- "${key}=${val}"
elif (( EUID > 0 )) ; then
(( multi > 0 )) && val="${val// ; / ; sudo }"
alias -- "${key}=sudo ${val}"
fi
return 0
}
# Check if we can read given files and source those we can.
function xsource () {
if (( ${#argv} < 1 )) ; then
printf 'usage: xsource FILE(s)...\n' >&2
return 1
fi
while (( ${#argv} > 0 )) ; do
[[ -r "$1" ]] && source "$1"
shift
done
return 0
}
# Check if we can read a given file and 'cat(1)' it.
function xcat () {
emulate -L zsh
if (( ${#argv} != 1 )) ; then
printf 'usage: xcat FILE\n' >&2
return 1
fi
[[ -r $1 ]] && cat $1
return 0
}
# Remove these functions again, they are of use only in these
# setup files. This should be called at the end of .zshrc.
function xunfunction () {
emulate -L zsh
local -a funcs
local func
funcs=(salias xcat xsource xunfunction zrcautoload zrcautozle)
for func in $funcs ; do
[[ -n ${functions[$func]} ]] \
&& unfunction $func
done
return 0
}
# this allows us to stay in sync with grml's zshrc and put own
# modifications in ~/.zshrc.local
function zrclocal () {
xsource "/etc/zsh/zshrc.local"
xsource "${ZDOTDIR:-${HOME}}/.zshrc.local"
return 0
}
# locale setup
if (( ZSH_NO_DEFAULT_LOCALE == 0 )); then
xsource "/etc/default/locale"
fi
for var in LANG LC_ALL LC_MESSAGES ; do
[[ -n ${(P)var} ]] && export $var
done
builtin unset -v var
# set some variables
if check_com -c vim ; then
#v#
export EDITOR=${EDITOR:-vim}
else
export EDITOR=${EDITOR:-vi}
fi
#v#
export PAGER=${PAGER:-less}
#v#
export MAIL=${MAIL:-/var/mail/$USER}
# color setup for ls:
check_com -c dircolors && eval $(dircolors -b)
# color setup for ls on OS X / FreeBSD:
isdarwin && export CLICOLOR=1
isfreebsd && export CLICOLOR=1
# do MacPorts setup on darwin
if isdarwin && [[ -d /opt/local ]]; then
# Note: PATH gets set in /etc/zprofile on Darwin, so this can't go into
# zshenv.
PATH="/opt/local/bin:/opt/local/sbin:$PATH"
MANPATH="/opt/local/share/man:$MANPATH"
fi
# do Fink setup on darwin
isdarwin && xsource /sw/bin/init.sh
# load our function and completion directories
for fdir in /usr/share/grml/zsh/completion /usr/share/grml/zsh/functions; do
fpath=( ${fdir} ${fdir}/**/*(/N) ${fpath} )
done
typeset -aU ffiles
ffiles=(/usr/share/grml/zsh/functions/**/[^_]*[^~](N.:t))
(( ${#ffiles} > 0 )) && autoload -U "${ffiles[@]}"
unset -v fdir ffiles
# support colors in less
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
# mailchecks
MAILCHECK=30
# report about cpu-/system-/user-time of command if running longer than
# 5 seconds
REPORTTIME=5
# watch for everyone but me and root
watch=(notme root)
# automatically remove duplicates from these arrays
typeset -U path PATH cdpath CDPATH fpath FPATH manpath MANPATH
# Load a few modules
is4 && \
for mod in parameter complist deltochar mathfunc ; do
zmodload -i zsh/${mod} 2>/dev/null || print "Notice: no ${mod} available :("
done && builtin unset -v mod
# autoload zsh modules when they are referenced
if is4 ; then
zmodload -a zsh/stat zstat
zmodload -a zsh/zpty zpty
zmodload -ap zsh/mapfile mapfile
fi
# completion system
COMPDUMPFILE=${COMPDUMPFILE:-${ZDOTDIR:-${HOME}}/.zcompdump}
if zrcautoload compinit ; then
typeset -a tmp
zstyle -a ':grml:completion:compinit' arguments tmp
compinit -d ${COMPDUMPFILE} "${tmp[@]}" || print 'Notice: no compinit available :('
unset tmp
else
print 'Notice: no compinit available :('
function compdef { }
fi
# completion system
# called later (via is4 && grmlcomp)
# note: use 'zstyle' for getting current settings
# press ^xh (control-x h) for getting tags in context; ^x? (control-x ?) to run complete_debug with trace output
function grmlcomp () {
# TODO: This could use some additional information
# Make sure the completion system is initialised
(( ${+_comps} )) || return 1
# allow one error for every three characters typed in approximate completer
zstyle ':completion:*:approximate:' max-errors 'reply=( $((($#PREFIX+$#SUFFIX)/3 )) numeric )'
# don't complete backup files as executables
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '(aptitude-*|*\~)'
# start menu completion only if it could find no unambiguous initial string
zstyle ':completion:*:correct:*' insert-unambiguous true
zstyle ':completion:*:corrections' format $'%{\e[0;31m%}%d (errors: %e)%{\e[0m%}'
zstyle ':completion:*:correct:*' original true
# activate color-completion
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
# format on completion
zstyle ':completion:*:descriptions' format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}'
# automatically complete 'cd -<tab>' and 'cd -<ctrl-d>' with menu
# zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
# insert all expansions for expand completer
zstyle ':completion:*:expand:*' tag-order all-expansions
zstyle ':completion:*:history-words' list false
# activate menu
zstyle ':completion:*:history-words' menu yes
# ignore duplicate entries
zstyle ':completion:*:history-words' remove-all-dups yes
zstyle ':completion:*:history-words' stop yes
# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# separate matches into groups
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*' group-name ''
if [[ "$NOMENU" -eq 0 ]] ; then
# if there are more than 5 options allow selecting from a menu
zstyle ':completion:*' menu select=5
else
# don't use any menus at all
setopt no_auto_menu
fi
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:options' auto-description '%d'
# describe options in full
zstyle ':completion:*:options' description 'yes'
# on processes completion complete all user processes
zstyle ':completion:*:processes' command 'ps -au$USER'
# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# provide verbose completion information
zstyle ':completion:*' verbose true
# recent (as of Dec 2007) zsh versions are able to provide descriptions
# for commands (read: 1st word in the line) that it will list for the user
# to choose from. The following disables that, because it's not exactly fast.
zstyle ':completion:*:-command-:*:' verbose false
# set format for warnings
zstyle ':completion:*:warnings' format $'%{\e[0;31m%}No matches for:%{\e[0m%} %d'
# define files to ignore for zcompile
zstyle ':completion:*:*:zcompile:*' ignored-patterns '(*~|*.zwc)'
zstyle ':completion:correct:' prompt 'correct to: %e'
# Ignore completion functions for commands you don't have:
zstyle ':completion::(^approximate*):*:functions' ignored-patterns '_*'
# Provide more processes in completion of programs like killall:
zstyle ':completion:*:processes-names' command 'ps c -u ${USER} -o command | uniq'
# complete manual by their section
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.*' insert-sections true
zstyle ':completion:*:man:*' menu yes select
# Search path for sudo completion
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
/usr/local/bin \
/usr/sbin \
/usr/bin \
/sbin \
/bin \
/usr/X11R6/bin
# provide .. as a completion
zstyle ':completion:*' special-dirs ..
# run rehash on completion so new installed program are found automatically: