dot/zshrc: Interpret `**' to cover files too, where sensible.
[profile] / dot / zshrc
1 ### -*-sh-*-
2 ###
3 ### Zsh session things.
4
5 __mdw_shell=zsh
6 case ${INSIDE_EMACS+t},$TERM in t,dumb) unsetopt zle ;; esac
7
8 . "$HOME/.shell-rc"
9
10 ###--------------------------------------------------------------------------
11 ### Prompt hacking.
12
13 __mdw_set_prompt_hacks () {
14 case $TERM in
15 linux*|screen*|xterm*|vt100*|eterm*)
16 bold=%B unbold=%b
17 gitcolour=%F{cyan} rccolour=%F{red} uncolour=%f
18 ;;
19 esac
20 host=%m dir=" %(6~!%-1~/.../%5~!%~)"
21 more=%F{green}%_%f
22 }
23
24 if [ -t 0 ]; then
25 __mdw_source_if_exists /usr/lib/git-core/git-sh-prompt
26 __mdw_set_prompt_pieces
27 precmd_functions+=(__mdw_precmd)
28 preexec_functions+=(__mdw_preexec)
29 fi
30
31 ###--------------------------------------------------------------------------
32 ### Line editing.
33
34 case $TERM in dumb) unsetopt zle ;; esac
35
36 bindkey -e
37
38 for w in \
39 forward-word backward-word kill-word backward-kill-word \
40 transpose-words capitalize-word up-case-word down-case-word \
41 delete-whole-word select-word
42 do
43 autoload -U $w-match
44 zle -N $w-bash $w-match
45 zle -N $w-shell $w-match
46 zstyle ':zle:*-bash' word-style standard
47 zstyle ':zle:*-bash' skip-whitespace-first true
48 zstyle ':zle:*-bash' word-chars ""
49 zstyle ':zle:*-shell' word-style shell
50 zstyle ':zle:*-shell' skip-whitespace-first false
51 done
52
53 bindkey "\eb" backward-word-bash
54 bindkey "\e^b" backward-word-shell
55 bindkey "\ef" forward-word-bash
56 bindkey "\e^f" forward-word-shell
57 bindkey "\e^?" backward-kill-word-bash
58 bindkey "^w" backward-kill-word-shell
59 bindkey "\ed" kill-word-bash
60 bindkey "\e^d" kill-word-shell
61 bindkey "\et" transpose-words-bash
62 bindkey "\e^t" transpose-words-shell
63 bindkey "\eu" up-case-word-bash
64 bindkey "\e^u" up-case-word-shell
65 bindkey "\el" down-case-word-bash
66 bindkey "\e^l" down-case-word-shell
67 bindkey "\ec" capitalize-word-bash
68 bindkey "\e^c" capitalize-word-shell
69
70 bindkey "\ep" history-beginning-search-backward
71 bindkey "\en" history-beginning-search-forward
72
73 setopt interactive_comments
74 bindkey "\e#" pound-insert
75
76 __mdw_delete_horizontal_space () {
77 LBUFFER=${LBUFFER%%[[:space:]]##}
78 RBUFFER=${RBUFFER##[[:space:]]##}
79 }
80 zle -N delete-horizontal-space __mdw_delete_horizontal_space
81 bindkey "\e\\" delete-horizontal-space
82
83 __mdw_just_one_space () {
84 LBUFFER="${LBUFFER%%[[:space:]]##} "
85 RBUFFER=${RBUFFER##[[:space:]]##}
86 }
87 zle -N just-one-space __mdw_just_one_space
88 bindkey "\e " just-one-space
89
90 ###--------------------------------------------------------------------------
91 ### Completion.
92
93 ## Contexts: :completion:FUNCTION:COMPLETER:COMMAND:ARGUMENT:TAG
94 zstyle ':completion:*' completer _expand _complete _ignored _approximate
95 zstyle ':completion:*' insert-unambiguous false
96 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
97 zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
98 zstyle ':completion:*' matcher-list '' '+m:{[:lower:]}={[:upper:]} r:|[._-]=** r:|=**' '+l:|=* r:|=*'
99 zstyle ':completion:*' max-errors 0 numeric
100 zstyle ':completion:*' original true
101 zstyle ':completion:*' verbose false
102 zstyle ':completion:*:*:git*:*' verbose true
103
104 ## Initialize the fancy completion machinery.
105 autoload -Uz compinit
106 compinit
107
108 _r () { words[1]=sudo; _normal; }
109 compdef _r rootly
110 compdef _ssh @
111
112 ###--------------------------------------------------------------------------
113 ### Other shell tweaking.
114
115 HISTFILE=~/.zsh-history
116 HISTSIZE=1000
117 SAVEHIST=1000
118
119 unsetopt auto_cd
120 unsetopt auto_menu
121 setopt bang_hist
122 unsetopt bash_auto_list
123 unsetopt beep
124 setopt extendedglob
125 unsetopt flow_control
126 setopt glob_star_short
127 setopt hist_ignore_all_dups
128 setopt hist_ignore_space
129 setopt ksh_glob
130 setopt list_ambiguous
131 setopt list_packed
132 setopt multios
133 unsetopt nomatch
134 unsetopt menu_complete
135 setopt notify
136 setopt rc_expand_param
137 setopt share_history
138
139 ###--------------------------------------------------------------------------
140 ### Finishing touches.
141
142 __mdw_source_if_exists "$HOME/.zshrc-local"
143
144 ###----- That's all, folks --------------------------------------------------