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