1f54e35a8d3c8321eef7361c5f88e4cc962e9f0d
[dotfiles/zsh.git] / zshrc
1 #!/bin/zsh
2
3 setopt auto_cd extended_glob auto_pushd pushd_ignore_dups
4 setopt hist_ignore_all_dups append_history extended_history hist_reduce_blanks
5 setopt correct complete_in_word
6 setopt prompt_subst transient_rprompt
7
8 HISTFILE=~/.histfile
9 HISTSIZE=10000
10 SAVEHIST=12000
11 DOMAIN=`hostname -f`
12
13 eval `dircolors`
14 eval `lesspipe`
15
16 export EDITOR="emacsclient -a '' -nw"
17 export PAGER=less
18
19 export LESS_TERMCAP_mb=$'\e[01;31m'
20 export LESS_TERMCAP_md=$'\e[01;31m'
21 export LESS_TERMCAP_me=$'\e[0m'
22 export LESS_TERMCAP_se=$'\e[0m'
23 export LESS_TERMCAP_so=$'\e[01;44;33m'
24 export LESS_TERMCAP_ue=$'\e[0m'
25 export LESS_TERMCAP_us=$'\e[01;32m'
26
27 autoload -Uz compinit
28 autoload -Uz vcs_info
29 autoload -Uz colors
30
31 compinit
32 vcs_info
33 colors
34
35 zmodload -i zsh/complist
36
37 _force_rehash() {
38 if (( CURRENT == 1 )); then
39 rehash
40 fi
41 # We didn't really complete anything.
42 return 1
43 }
44
45 zstyle :compinstall filename '/home/christoph/.zshrc'
46 zstyle ':completion:*' menu select=3
47 zstyle -e ':completion::*:*:*:hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2|_uni|_debian)(N) /dev/null)"}%%[# ]*}//,/ })'
48 zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
49 zstyle ':completion:::::' completer _force_rehash _complete _approximate _expand _ignored
50
51 bindkey -e
52 bindkey '\ee' backward-word
53 bindkey '\ef' forward-word
54 bindkey '\e[B' down-line-or-search
55 bindkey '\e[A' up-line-or-search
56 bindkey '\e[28~' run-help
57
58
59
60 setWindowTitle(){
61 echo -e '\033]0;'$1'\007'
62 }
63
64 precmd () {
65 vcs_info
66 setWindowTitle ${USER}@${HOST}
67
68 if [[ $UID == 0 && $+commands[systemctl] != 0 ]]
69 then
70 use_systemd=true
71 systemd_failed="`systemctl --state=failed | grep failed | cut -d \ -f 2 | tr '\n' ' '`"
72 fi
73 }
74
75 config=("default" "`uname -s`")
76
77 case "${DOMAIN//cs.fau.de/informatik.uni-erlangen.de}" in
78 (*.debian.org)
79 export EMAIL=christoph@debian.org
80 config=($config debian)
81 ;;
82 (faui49*.uni-erlangen.de)
83 export EMAIL=Christoph.Egger@cs.fau.de
84 config=($config i4lab)
85 ;;
86 (faui0*.informatik.uni-erlangen.de|faui48*.informatik.uni-erlangen.de)
87 export EMAIL=siccegge@cs.fau.de
88 config=($config cip)
89 ;;
90 (*.siccegge.de)
91 export MAIL=christoph@christoph-egger.org
92 config=($config home)
93 ;;
94 esac
95
96 if [[ $UID == 0 && $+commands[systemctl] != 0 ]]
97 then
98 PROMPT=$'%{$fg[red]>> $systemd_failed$reset_color%}\n'
99 else
100 PROMPT=""
101 fi
102
103 PROMPT+=$'%{$fg[yellow]%}%n@%{$fg[magenta]%}%m%{$reset_color%} %~ \n%{$fg[cyan]%}%T%{$reset_color%} %0(?,%{$fg[green]%},%{$fg[red]%}%s)%?%{$reset_color%} %# '
104
105 RPROMPT='${vcs_info_msg_0_}'
106
107 export DEBEMAIL='christoph@debian.org'
108 export DEBFULLNAME='Christoph Egger'
109 export DEB_BUILD_OPTIONS="parallel=$(getconf _NPROCESSORS_ONLN)"
110
111
112 for ftype in aliases includes
113 do
114 for location in $config
115 do
116 if [ -f ~/.zsh/${ftype}/${location}.zsh ]
117 then
118 source ~/.zsh/${ftype}/${location}.zsh
119 fi
120 done
121 done
122
123
124
125 karma () {
126 gpg --fingerprint $1 >> ${HOME}/karma
127 printf '\n-----\n\n' >> ${HOME}/karma
128 }
129
130 gpgrefresh () {
131 gpg --refresh-keys 2>&1 | grep -v 'nicht geƤndert'
132 }
133
134 sponsor() {
135 pkgname=`echo $i | rcut -d '/' -f 1 | cut -d '_' -f 1`
136 apt-get --download-only -t unstable $pkgname
137 dget $i
138 }
139
140 path=(${HOME}/bin $path)
141 fpath=(${HOME}/.zsh/functions/$CONFIG ${HOME}/.zsh/functions/default $fpath)
142
143 export PATH
144 export FPATH
145
146 alias wb="ssh -t buildd.debian.org wb"