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