1 # Zsh configuration file.
4 # Use Vi(m) style key bindings.
7 # Be paranoid, new files are readable/writable by me only.
10 # Use history and store it in ~/.zsh/history.
13 HISTFILE=~/.zsh/history
14 # Append to the history file instead of overwriting it and do it immediately
15 # when a command is executed.
17 setopt incappendhistory
18 # If the same command is run multiple times store it only once in the history.
20 # Vim like completions of previous executed commands.
21 bindkey "^P" history-beginning-search-backward
22 bindkey "^N" history-beginning-search-forward
24 # Prevent overwriting existing files with '> filename'.
27 # Entering the name of a directory (if it's not a command) will automatically
28 # cd to that directory.
31 # When entering a nonexistent command name automatically try to find a similar
35 # Use colorized output, necessary for prompts and completions.
36 autoload -U colors && colors
38 # Set the default prompt. The current host and working directory is displayed,
39 # the exit code of the last command if it wasn't 0, the number of running jobs
40 # if not 0 and a + if this shell is running inside another shell.
41 # The prompt is in green and blue to make easily detectable, the error exit
42 # code in red and bold and the job count in yellow.
43 PROMPT="%{${fg[green]}%}%B%m%b%{${fg[default]}%}:\
44 %{${fg[blue]}%}%B%~%b%{${fg[default]}%} \
45 %(1j.%{${fg[yellow]}%}%j%{${fg[default]}%}.)%(2L.+.)%# \
46 %(?..(%{${fg[red]}%}%B%?%b%{${fg[default]}%}%) )"
48 # Use new completion system.
49 autoload -U compinit && compinit
50 # Load the complist module which provides additions to completion lists
51 # (coloring, scrollable).
53 # Make sure the list of possible completions is displayed after pressing <TAB>
55 setopt nolistambiguous
56 # Allow completions in the middle of a text, i.e. "/usr/bin/<TAB>whatever"
57 # completes like "/usr/bin/<TAB>". Useful when adding new options to commands.
58 bindkey "^I" expand-or-complete-prefix
59 # Use cache to speed up completions.
60 zstyle ':completion:*' use-cache on
61 zstyle ':completion:*' cache-path ~/.zsh/cache
62 # Ignore case if currently typed string doesn't match.
63 zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
64 # Ignore completion functions.
65 zstyle ':completion:*:functions' ignored-patterns '_*'
66 # Ignore parent directory.
67 zstyle ':completion:*:(cd|mv|cp):*' ignore-parents parent pwd
68 # Use ls like colors for completions.
69 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
70 # Make completion lists scrollable so "do you wish to see all n possibilities"
71 # is no longer displayed.
72 zstyle ':completion:*' list-prompt '%p'
74 # Enable zsh's extended glob abilities.
77 # Don't exit if <C-d> is pressed.
80 # If ^C is pressed while typing a command, add it to the history so it can be
81 # easily retrieved later and then abort like ^C normally does. This is useful
82 # when I want to abort an command to do something in between and then finish
85 # Store the current buffer in the history.
86 zle && print -s $BUFFER
88 # Return the default exit code so zsh aborts the current command.
92 # Simplify calls to less, automatically redirects all output.
93 alias -g L='2>&1 | less'
94 # Simplify calls to colordiff, output is also piped through less.
95 alias -g D='2>&1 | colordiff L'
96 # Simplify calls to grep.
99 # Improved ls which displays the files in columns (-C), visualises directories,
100 # links and other special files (-F) and pages everything through less (L).
102 command ls -C -F $* L
104 # Helper function to list all files.
108 # Helper function to list all files in list format with access rights, etc.
114 # Load rc file for current hostname (first part before a dot) or rc.local.
115 source_config ~/.zsh "" rc ${$(hostname)//.*/}