1 # Zsh configuration file.
4 # Use Vi(m) style key bindings.
7 # Use history and store it in ~/.zsh/history.
10 HISTFILE=~/.zsh/history
11 # Append to the history file instead of overwriting it and do it immediately
12 # when a command is executed.
14 setopt incappendhistory
15 # If the same command is run multiple times store it only once in the history.
17 # Vim like completions of previous executed commands.
18 bindkey "^P" history-beginning-search-backward
19 bindkey "^N" history-beginning-search-forward
21 # Prevent overwriting existing files with '> filename'.
24 # Entering the name of a directory (if it's not a command) will automatically
25 # cd to that directory.
28 # When entering a nonexistent command name automatically try to find a similar
32 # Use colorized output.
33 autoload -U colors && colors
34 # Set the default prompt. The current host and working directory is displayed,
35 # the exit code of the last command if it wasn't 0 and a + if this shell is
36 # running inside another shell.
37 # The prompt is in green and blue to make easily detectable, the error exit
38 # code in red and bold.
39 PROMPT="%{${fg[green]}%}%B%m%b%{${fg[default]}%}:\
40 %{${fg[blue]}%}%B%~%b%{${fg[default]}%} %(2L.+.)%# \
41 %(?..(%{${fg[red]}%}%B%?%b%{${fg[default]}%}%) )"
43 # Use new completion system.
44 autoload -U compinit && compinit
45 # Make sure the list of possible completions is displayed after pressing <TAB>
47 setopt nolistambiguous
48 # Use cache to speed up completions.
49 zstyle ':completion:*' use-cache on
50 zstyle ':completion:*' cache-path ~/.zsh/cache
51 # Ignore case if currently typed string doesn't match.
52 zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
54 # Enable zsh's extended glob abilities.
57 # If ^C is pressed while typing a command, copy it in the kill buffer so it can
58 # be "yanked" later and then abort like ^C normally does. This is useful when I
59 # want to abort an command to do something in between and then finish typing
62 # Kill the current buffer so it gets stored and can be retrieved later with
63 # "yank". Then yank it so it gets displayed (otherwise I don't know which
65 zle && zle kill-buffer && zle yank
67 # Return the default exit code so zsh aborts the current command line.
70 # Make sure ^Y is bound to yank, necessary for the TRAPINT function to work as
74 # Simplify calls to less, automatically redirects all output.
75 alias -g L='2>&1 | less'
76 # Simplify calls to colordiff, output is also piped through less.
77 alias -g D='2>&1 | colordiff L'
78 # Simplify calls to grep.
82 # If a rc.local file exists load it, otherwise load a rc file for the current
83 # hostname (first part before a dot) if it exists.
84 host=${$(hostname)//.*/}
85 if [[ -f ~/.zsh/rc.local ]]; then;
86 source ~/.zsh/rc.local
87 elif [[ -f ~/.zsh/rc.$host ]]; then;
88 source ~/.zsh/rc.$host