dot/zshrc: Write numbers in odd bases using C notation.
[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 ###--------------------------------------------------------------------------
9 ### History settings.
10
11 ## Put this here so that `.shellrc-local' can override.
12
13 HISTFILE=~/.zsh-history
14 HISTSIZE=1000
15 SAVEHIST=1000
16
17 ###--------------------------------------------------------------------------
18 ### Common shell configuration.
19
20 . "$HOME/.shell-rc"
21
22 ###--------------------------------------------------------------------------
23 ### Prompt hacking.
24
25 __mdw_set_prompt_hacks () {
26 case $TERM in
27 linux*|screen*|xterm*|putty*|vt100*|eterm*)
28 bold=%B unbold=%b
29 gitcolour=%F{cyan} rccolour=%F{red} uncolour=%f
30 ;;
31 esac
32 host=%m dir=" %(6~!%-1~/.../%4~!%~)"
33 more=%F{green}%_%f
34 }
35
36 if [ -t 0 ]; then
37 __mdw_source_if_exists /usr/lib/git-core/git-sh-prompt
38 __mdw_set_prompt_pieces
39 precmd_functions+=(__mdw_precmd)
40 preexec_functions+=(__mdw_preexec)
41 fi
42
43 ###--------------------------------------------------------------------------
44 ### Line editing.
45
46 case $TERM in dumb) unsetopt zle ;; esac
47
48 bindkey -e
49
50 for w in \
51 forward-word backward-word kill-word backward-kill-word \
52 transpose-words capitalize-word up-case-word down-case-word \
53 delete-whole-word select-word
54 do
55 autoload -U $w-match
56 zle -N $w-bash $w-match
57 zle -N $w-shell $w-match
58 zstyle ':zle:*-bash' word-style standard
59 zstyle ':zle:*-bash' skip-whitespace-first true
60 zstyle ':zle:*-bash' word-chars ""
61 zstyle ':zle:*-shell' word-style shell
62 zstyle ':zle:*-shell' skip-whitespace-first false
63 done
64
65 bindkey "\eb" backward-word-bash
66 bindkey "\e^b" backward-word-shell
67 bindkey "\ef" forward-word-bash
68 bindkey "\e^f" forward-word-shell
69 bindkey "\e^?" backward-kill-word-bash
70 bindkey "^w" backward-kill-word-shell
71 bindkey "\ed" kill-word-bash
72 bindkey "\e^d" kill-word-shell
73 bindkey "\et" transpose-words-bash
74 bindkey "\e^t" transpose-words-shell
75 bindkey "\eu" up-case-word-bash
76 bindkey "\e^u" up-case-word-shell
77 bindkey "\el" down-case-word-bash
78 bindkey "\e^l" down-case-word-shell
79 bindkey "\ec" capitalize-word-bash
80 bindkey "\e^c" capitalize-word-shell
81
82 bindkey "\e[1~" beginning-of-line "\e[4~" end-of-line
83
84 bindkey -s "\eOQ" "/" "\eOR" "*" "\eOS" "-"
85 bindkey -s "\eOw" "7" "\eOx" "8" "\eOy" "9"
86 bindkey -s "\eOt" "4" "\eOu" "5" "\eOv" "6" "\eOk" "+"
87 bindkey -s "\eOq" "1" "\eOr" "2" "\eOs" "3"
88 bindkey -s "\eOp" "0" "\eOn" "."; bindkey "\eOM" accept-line
89
90 bindkey -s "\eOQ" "/" "\eOR" "*" "\eOS" "-"
91 bindkey -s "\eOw" "7" "\eOx" "8" "\eOy" "9"
92 bindkey -s "\eOt" "4" "\eOu" "5" "\eOv" "6" "\eOk" "+"
93 bindkey -s "\eOq" "1" "\eOr" "2" "\eOs" "3"
94 bindkey -s "\eOp" "0" "\eOn" "."; bindkey "\eOM" accept-line
95
96 bindkey "\ep" history-beginning-search-backward
97 bindkey "\en" history-beginning-search-forward
98 bindkey "\e," _history-complete-older
99
100 for i in '!' '$' '@' '/' '~'; do
101 bindkey "\e$i" _bash_complete-word
102 bindkey "^X$i" _bash_list-choices
103 done
104
105 setopt interactive_comments
106 bindkey "\e#" pound-insert
107
108 __mdw_delete_horizontal_space () {
109 LBUFFER=${LBUFFER%%[[:space:]]##}
110 RBUFFER=${RBUFFER##[[:space:]]##}
111 }
112 zle -N delete-horizontal-space __mdw_delete_horizontal_space
113 bindkey "\e\\" delete-horizontal-space
114
115 __mdw_just_one_space () {
116 LBUFFER="${LBUFFER%%[[:space:]]##} "
117 RBUFFER=${RBUFFER##[[:space:]]##}
118 }
119 zle -N just-one-space __mdw_just_one_space
120 bindkey "\e " just-one-space
121
122 ###--------------------------------------------------------------------------
123 ### Completion.
124
125 ## Contexts: :completion:FUNCTION:COMPLETER:COMMAND:ARGUMENT:TAG
126 zstyle ':completion:*' completer _expand _complete _ignored _approximate
127 zstyle ':completion:*' insert-unambiguous false
128 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
129 zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
130 zstyle ':completion:*' matcher-list '' '+m:{[:lower:]}={[:upper:]} r:|[._-]=** r:|=**' '+l:|=* r:|=*'
131 zstyle ':completion:*' max-errors 0 numeric
132 zstyle ':completion:*' original true
133 zstyle ':completion:*' verbose false
134 zstyle ':completion:*:*:git*:*' verbose true
135
136 ## Initialize the fancy completion machinery.
137 autoload -Uz compinit
138 compinit
139
140 _r () { words[1]=sudo; _normal; }
141 compdef _r rootly
142 compdef _ssh @
143
144 ###--------------------------------------------------------------------------
145 ### Other shell tweaking.
146
147 unsetopt auto_cd
148 unsetopt auto_menu
149 setopt bang_hist
150 unsetopt bash_auto_list
151 unsetopt beep
152 setopt c_bases octal_zeroes
153 setopt extendedglob
154 unsetopt flow_control
155 unsetopt global_export
156 setopt glob_star_short
157 setopt hist_ignore_all_dups
158 setopt hist_ignore_space
159 unsetopt ksh_glob
160 setopt list_ambiguous
161 setopt list_packed
162 setopt multios
163 unsetopt nomatch
164 unsetopt menu_complete
165 setopt notify
166 setopt rc_expand_param
167 setopt share_history
168
169 hash -d t=$TMPDIR
170
171 ###--------------------------------------------------------------------------
172 ### Finishing touches.
173
174 ## Local tweaks.
175 __mdw_source_if_exists "$HOME/.zshrc-local"
176
177 ###----- That's all, folks --------------------------------------------------