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