zsh: Update
[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
11 autoload -U compinit promptinit
12 compinit
13 zstyle ':completion::complete:*' use-cache 1
14
15 autoload colors zsh/terminfo
16 if [[ "$terminfo[colors]" -ge 8 ]]; then
17 colors
18 fi
19
20 eval `dircolors`
21 LS_COLORS="${LS_COLORS}*.divx=01;35:"
22 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
23
24 zstyle ':completion:*' menu select
25 zmodload -i zsh/complist
26
27 # bind special keys according to readline configuration
28 #eval "$(sed -n 's/^/bindkey /; s/: / /p' /etc/inputrc)"
29
30 bindkey "\e[1~" beginning-of-line
31 bindkey "\e[4~" end-of-line
32 bindkey "\e[5~" history-search-backward
33 bindkey "\e[6~" history-search-forward
34 bindkey "\e[3~" delete-char
35 bindkey "\e[2~" quoted-insert
36 bindkey "\e[5C" forward-word
37 bindkey "\e[5D" backward-word
38 bindkey "\e\e[C" forward-word
39 bindkey "\e\e[D" backward-word
40 bindkey "\e[1;5C" forward-word
41 bindkey "\e[1;5D" backward-word
42 bindkey "\eOc" forward-word
43 bindkey "\eOd" backward-word
44 bindkey "\e[1;3C" forward-word
45 bindkey "\e[1;3D" backward-word
46 bindkey "\e[8~" end-of-line
47 bindkey "\eOH" beginning-of-line
48 bindkey "\eOF" end-of-line
49 bindkey "\e[H" beginning-of-line
50 bindkey "\e[F" end-of-line
51 bindkey "\e[7~" beginning-of-line
52 bindkey "\e[8~" end-of-line
53
54
55
56 setopt \
57 EXTENDEDGLOB \
58 BASH_AUTO_LIST \
59 LIST_AMBIGUOUS \
60 CHECK_JOBS \
61 INC_APPEND_HISTORY \
62 HIST_IGNORE_DUPS \
63 HIST_IGNORE_SPACE \
64 NO_HUP
65
66
67 HISTFILE=~/.zsh_history
68 HISTSIZE=50000
69 SAVEHIST=50000
70 REPORTTIME=5
71 TIMEFMT="$fg[magenta]%J %U user %S sys %P cpu %*E total %M MB RSS max$terminfo[sgr0]"
72
73 autoload -Uz vcs_info && vcs_info
74 zstyle ':vcs_info:*' enable git cvs svn hg
75 zstyle ':vcs_info:*' use-prompt-escapes
76 zstyle ':vcs_info:*' max-exports 1
77
78
79 function setprompt()
80 {
81 # default: " (%s)-[%b|%a]%u%c-"
82 zstyle ':vcs_info:*' actionformats " %s: %b|%a"
83 # default: " (%s)-[%b]%u%c-"
84 zstyle ':vcs_info:*' formats " %s: %b"
85
86 setopt PROMPT_SUBST
87 PROMPT='
88 %(!.%{$fg_bold[red]%}.%{$fg_bold[green]%})%n@%m%{$reset_color%}$PR_SCREEN$PR_JOBS%{$fg_bold[yellow]%}${vcs_info_msg_0_}%{$reset_color%} %{$fg_bold[blue]%}%~%{$reset_color%}
89 $PR_EXIT%# '
90 }
91 setprompt
92
93 # Obtain the autofs mountpoints
94 autofs_mp=()
95 [ -r /etc/auto.master ] && autofs_mp=($(/bin/grep -e "^/" /etc/auto.master | cut -f1))
96
97 function precmd ()
98 {
99 PR_EXIT="%{$fg_bold[red]%}%(?..[%?] )%{$reset_color%}"
100
101 # Check whether current directory is a subdirectory of an autofs mountpoint
102 local parent="0"
103 vcs_info_msg_0_=""
104 for mp in ${autofs_mp}; do
105 # A parent directory is an autofs mount point
106 if echo "$PWD" | /bin/grep -q $mp; then
107 parent="1"
108 # Even equal!
109 if echo "$mp" | /bin/grep -q $PWD; then
110 vcs_info_msg_0_=" [autofs]"
111 fi
112 break;
113 fi
114 done
115 if [ -z "$vcs_info_msg_0_" ]; then
116 if [ "$parent" = "1" ]; then
117 # svn and hg cause complaints of autofs that .svn and .hg is no mount point
118 zstyle ':vcs_info:*' enable git cvs
119 else
120 zstyle ':vcs_info:*' enable git cvs svn hg
121 fi
122 vcs_info
123 fi
124
125 PR_SCREEN=""
126 if [[ -n "${WINDOW}" ]]; then
127 PR_SCREEN=" S:${WINDOW}"
128 fi
129
130 PR_JOBS=""
131 if [[ $(jobs | wc -l) -gt 0 ]]; then
132 PR_JOBS=" J:%j"
133 fi
134
135 }
136
137
138