zshrc: do not vcs_info in autofs mountpoints
[shutils.git] / dotfiles / shell / zshrc
1 # sample by Peter Palfrader: http://svn.noreply.org/svn/weaselutils/trunk/dotfiles/zshrc
2
3 [ -r /etc/zsh/zprofile ] && source /etc/zsh/zprofile
4 [ -r $HOME/.profile ] && source $HOME/.profile
5
6
7 bindkey -e
8 zstyle :compinstall filename "$HOME/.zshrc"
9
10 autoload -Uz compinit
11 compinit
12
13 if [ -e $HOME/.bash_completion ]; then
14 autoload bashcompinit
15 bashcompinit
16 source $HOME/.bash_completion
17 fi
18
19 autoload colors zsh/terminfo
20 if [[ "$terminfo[colors]" -ge 8 ]]; then
21 colors
22 fi
23
24 eval `dircolors`
25 LS_COLORS="${LS_COLORS}*.divx=01;35:"
26 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
27
28 TERM=xterm-256color
29
30 zstyle ':completion:*' menu select
31 zmodload -i zsh/complist
32
33
34
35 # bind special keys according to readline configuration
36 #eval "$(sed -n 's/^/bindkey /; s/: / /p' /etc/inputrc)"
37
38 bindkey "\e[1~" beginning-of-line
39 bindkey "\e[4~" end-of-line
40 bindkey "\e[5~" history-search-backward
41 bindkey "\e[6~" history-search-forward
42 bindkey "\e[3~" delete-char
43 bindkey "\e[2~" quoted-insert
44 bindkey "\e[5C" forward-word
45 bindkey "\e[5D" backward-word
46 bindkey "\e\e[C" forward-word
47 bindkey "\e\e[D" backward-word
48 bindkey "\e[1;5C" forward-word
49 bindkey "\e[1;5D" backward-word
50 bindkey "\eOc" forward-word
51 bindkey "\eOd" backward-word
52 bindkey "\e[1;3C" forward-word
53 bindkey "\e[1;3D" backward-word
54 bindkey "\e[8~" end-of-line
55 bindkey "\eOH" beginning-of-line
56 bindkey "\eOF" end-of-line
57 bindkey "\e[H" beginning-of-line
58 bindkey "\e[F" end-of-line
59 bindkey "\e[7~" beginning-of-line
60 bindkey "\e[8~" end-of-line
61
62
63
64 setopt \
65 EXTENDEDGLOB \
66 BASH_AUTO_LIST \
67 LIST_AMBIGUOUS \
68 CHECK_JOBS \
69 INC_APPEND_HISTORY \
70 HIST_IGNORE_DUPS \
71 HIST_IGNORE_SPACE \
72 NO_HUP
73
74
75 for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
76 eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
77 eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
78 done
79 PR_BOLD="%{$terminfo[bold]%}"
80 PR_NO_COLOUR="%{$terminfo[sgr0]%}"
81
82 HISTFILE=~/.zsh_history
83 HISTSIZE=50000
84 SAVEHIST=50000
85 REPORTTIME=5
86 TIMEFMT="$terminfo[bold]$fg[yellow]%J %U user %S sys %P cpu %*E total %M kB max$terminfo[sgr0]"
87
88 autoload -Uz vcs_info && vcs_info
89 zstyle ':vcs_info:*' enable git cvs svn hg
90 zstyle ':vcs_info:*' use-prompt-escapes
91 zstyle ':vcs_info:*' max-exports 1
92
93
94 function setprompt()
95 {
96 # default: " (%s)-[%b|%a]%u%c-"
97 zstyle ':vcs_info:*' actionformats "${PR_YELLOW}%s:%b|%a${PR_NO_COLOUR} "
98 # default: " (%s)-[%b]%u%c-"
99 zstyle ':vcs_info:*' formats "${PR_YELLOW}%s:%b${PR_NO_COLOUR} "
100
101 setopt PROMPT_SUBST
102 PROMPT='%(!.$PR_RED.$PR_GREEN)%n@%m $PR_BLUE%1~ %# $PR_NO_COLOUR'
103 RPROMPT='${vcs_info_msg_0_}${PR_STUFF}'
104 }
105 setprompt
106
107
108 function precmd ()
109 {
110 local exitstatus="${?}"
111 PR_STUFF=" "
112 if [[ 0 -ne "${exitstatus}" ]] ; then
113 PR_STUFF="${PR_RED}RET ${exitstatus}${PR_NO_COLOUR}"
114 fi
115
116 # autofs always complains not being able to mount .hg/ and the like
117 if [ -r /etc/auto.master ] && grep -qe "^$PWD\s" /etc/auto.master; then
118 vcs_info_msg_0_=""
119 else
120 vcs_info
121 fi
122 }
123
124
125