]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - zsh/rc
Simplified loading of config files by using a function.
[config/dotfiles.git] / zsh / rc
1 # Zsh configuration file.
2
3
4 # Use Vi(m) style key bindings.
5 bindkey -v
6
7 # Be paranoid, new files are readable/writable by me only.
8 umask 077
9
10 # Use history and store it in ~/.zsh/history.
11 HISTSIZE=1000
12 SAVEHIST=1000
13 HISTFILE=~/.zsh/history
14 # Append to the history file instead of overwriting it and do it immediately
15 # when a command is executed.
16 setopt appendhistory
17 setopt incappendhistory
18 # If the same command is run multiple times store it only once in the history.
19 setopt histignoredups
20 # Vim like completions of previous executed commands.
21 bindkey "^P" history-beginning-search-backward
22 bindkey "^N" history-beginning-search-forward
23
24 # Prevent overwriting existing files with '> filename'.
25 setopt noclobber
26
27 # Entering the name of a directory (if it's not a command) will automatically
28 # cd to that directory.
29 setopt autocd
30
31 # When entering a nonexistent command name automatically try to find a similar
32 # one.
33 setopt correct
34
35 # Use colorized output, necessary for prompts and completions.
36 autoload -U colors && colors
37
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 and a + if this shell is
40 # 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.
43 PROMPT="%{${fg[green]}%}%B%m%b%{${fg[default]}%}:\
44 %{${fg[blue]}%}%B%~%b%{${fg[default]}%} %(2L.+.)%# \
45 %(?..(%{${fg[red]}%}%B%?%b%{${fg[default]}%}%) )"
46
47 # Use new completion system.
48 autoload -U compinit && compinit
49 # Load the complist module which provides additions to completion lists
50 # (coloring, scrollable).
51 zmodload zsh/complist
52 # Make sure the list of possible completions is displayed after pressing <TAB>
53 # the first time.
54 setopt nolistambiguous
55 # Allow completions in the middle of a text, i.e. "/usr/bin/<TAB>whatever"
56 # completes like "/usr/bin/<TAB>". Useful when adding new options to commands.
57 bindkey "^I" expand-or-complete-prefix
58 # Use cache to speed up completions.
59 zstyle ':completion:*' use-cache on
60 zstyle ':completion:*' cache-path ~/.zsh/cache
61 # Ignore case if currently typed string doesn't match.
62 zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
63 # Ignore completion functions.
64 zstyle ':completion:*:functions' ignored-patterns '_*'
65 # Ignore parent directory.
66 zstyle ':completion:*:(cd|mv|cp):*' ignore-parents parent pwd
67 # Use ls like colors for completions.
68 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
69 # Make completion lists scrollable so "do you wish to see all n possibilities"
70 # is no longer displayed.
71 zstyle ':completion:*' list-prompt '%p'
72
73 # Enable zsh's extended glob abilities.
74 setopt extendedglob
75
76 # Don't exit if <C-d> is pressed.
77 setopt ignoreeof
78
79 # If ^C is pressed while typing a command, add it to the history so it can be
80 # easily retrieved later and then abort like ^C normally does. This is useful
81 # when I want to abort an command to do something in between and then finish
82 # typing the command.
83 TRAPINT() {
84     # Store the current buffer in the history.
85     zle && print -s $BUFFER
86
87     # Return the default exit code so zsh aborts the current command.
88     return $1
89 }
90
91 # Simplify calls to less, automatically redirects all output.
92 alias -g L='2>&1 | less'
93 # Simplify calls to colordiff, output is also piped through less.
94 alias -g D='2>&1 | colordiff L'
95 # Simplify calls to grep.
96 alias -g G='| grep'
97
98 # Improved ls which displays the files in columns (-C), visualises directories,
99 # links and other special files (-F) and pages everything through less (L).
100 function ls() {
101     command ls -C -F $* L
102 }
103 # Helper function to list all files.
104 function la() {
105     ls -a $*
106 }
107 # Helper function to list all files in list format with access rights, etc.
108 function ll() {
109     la -l $*
110 }
111
112
113 # Load rc file for current hostname (first part before a dot) or rc.local.
114 source_config ~/.zsh "" rc ${$(hostname)//.*/}