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