bin/wakey.sh: Delete bogus space.
[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###--------------------------------------------------------------------------
4877b8d8
MW
18### Hook implementation.
19
20__mdw_precmd_hook= __mdw_preexec_hook=
21
22__mdw_run_precmd_hook () { __mdw_runhook __mdw_precmd_hook "$@"; }
23__mdw_run_preexec_hook () { __mdw_runhook __mdw_preexec_hook "$@"; }
24
25precmd_functions+=(__mdw_run_precmd_hook)
26preexec_functions+=(__mdw_run_preexec_hook)
27
28###--------------------------------------------------------------------------
3b41df91
MW
29### Common shell configuration.
30
a797cf50
MW
31. "$HOME/.shell-rc"
32
4877b8d8
MW
33## Fixup: `zsh' has sane quoting rules.
34__mdw_runhook () {
35 local hk=$1 saverc=$? t i; shift
36
37 eval t=\${$hk+t}
38 case $t in t) ;; *) echo >&2 "unknown hook \`$hk'"; return 2; esac
39
40 eval t=\$$hk
41 for i in ${=t}; do __mdw_setrc $saverc; "$i" "$@"; done
42}
43
a797cf50
MW
44###--------------------------------------------------------------------------
45### Prompt hacking.
46
47__mdw_set_prompt_hacks () {
48 case $TERM in
8a075bd7 49 linux*|screen*|xterm*|putty*|vt100*|eterm*)
a797cf50
MW
50 bold=%B unbold=%b
51 gitcolour=%F{cyan} rccolour=%F{red} uncolour=%f
52 ;;
53 esac
3fa9aa25 54 host=%m dir=" %(6~!%-1~/.../%4~!%~)"
778e2af4 55 more=%F{green}%_%f
a797cf50
MW
56}
57
58if [ -t 0 ]; then
59 __mdw_source_if_exists /usr/lib/git-core/git-sh-prompt
60 __mdw_set_prompt_pieces
a797cf50
MW
61fi
62
63###--------------------------------------------------------------------------
64### Line editing.
65
dbd3e351
MW
66case $TERM in dumb) unsetopt zle ;; esac
67
a797cf50
MW
68bindkey -e
69
d7b20e5c
MW
70for w in \
71 forward-word backward-word kill-word backward-kill-word \
72 transpose-words capitalize-word up-case-word down-case-word \
73 delete-whole-word select-word
74do
75 autoload -U $w-match
76 zle -N $w-bash $w-match
77 zle -N $w-shell $w-match
78 zstyle ':zle:*-bash' word-style standard
79 zstyle ':zle:*-bash' skip-whitespace-first true
80 zstyle ':zle:*-bash' word-chars ""
81 zstyle ':zle:*-shell' word-style shell
82 zstyle ':zle:*-shell' skip-whitespace-first false
83done
84
85bindkey "\eb" backward-word-bash
86bindkey "\e^b" backward-word-shell
87bindkey "\ef" forward-word-bash
88bindkey "\e^f" forward-word-shell
89bindkey "\e^?" backward-kill-word-bash
90bindkey "^w" backward-kill-word-shell
91bindkey "\ed" kill-word-bash
92bindkey "\e^d" kill-word-shell
93bindkey "\et" transpose-words-bash
94bindkey "\e^t" transpose-words-shell
95bindkey "\eu" up-case-word-bash
96bindkey "\e^u" up-case-word-shell
e3674277
MW
97bindkey "\el" down-case-word-bash
98bindkey "\e^l" down-case-word-shell
d7b20e5c
MW
99bindkey "\ec" capitalize-word-bash
100bindkey "\e^c" capitalize-word-shell
101
2a0e079f
MW
102bindkey "\e[1~" beginning-of-line "\e[4~" end-of-line
103
104bindkey -s "\eOQ" "/" "\eOR" "*" "\eOS" "-"
105bindkey -s "\eOw" "7" "\eOx" "8" "\eOy" "9"
106bindkey -s "\eOt" "4" "\eOu" "5" "\eOv" "6" "\eOk" "+"
107bindkey -s "\eOq" "1" "\eOr" "2" "\eOs" "3"
108bindkey -s "\eOp" "0" "\eOn" "."; bindkey "\eOM" accept-line
109
110bindkey -s "\eOQ" "/" "\eOR" "*" "\eOS" "-"
111bindkey -s "\eOw" "7" "\eOx" "8" "\eOy" "9"
112bindkey -s "\eOt" "4" "\eOu" "5" "\eOv" "6" "\eOk" "+"
113bindkey -s "\eOq" "1" "\eOr" "2" "\eOs" "3"
114bindkey -s "\eOp" "0" "\eOn" "."; bindkey "\eOM" accept-line
115
eda14eb9
MW
116bindkey "\ep" history-beginning-search-backward
117bindkey "\en" history-beginning-search-forward
af8517d9
MW
118bindkey "\e," _history-complete-older
119
120for i in '!' '$' '@' '/' '~'; do
121 bindkey "\e$i" _bash_complete-word
122 bindkey "^X$i" _bash_list-choices
123done
eda14eb9 124
a897ee2c
MW
125setopt interactive_comments
126bindkey "\e#" pound-insert
127
c510f8b9
MW
128__mdw_delete_horizontal_space () {
129 LBUFFER=${LBUFFER%%[[:space:]]##}
130 RBUFFER=${RBUFFER##[[:space:]]##}
131}
132zle -N delete-horizontal-space __mdw_delete_horizontal_space
133bindkey "\e\\" delete-horizontal-space
134
135__mdw_just_one_space () {
136 LBUFFER="${LBUFFER%%[[:space:]]##} "
137 RBUFFER=${RBUFFER##[[:space:]]##}
138}
139zle -N just-one-space __mdw_just_one_space
140bindkey "\e " just-one-space
141
a797cf50
MW
142###--------------------------------------------------------------------------
143### Completion.
144
a797cf50
MW
145## Contexts: :completion:FUNCTION:COMPLETER:COMMAND:ARGUMENT:TAG
146zstyle ':completion:*' completer _expand _complete _ignored _approximate
147zstyle ':completion:*' insert-unambiguous false
148zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
149zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
150zstyle ':completion:*' matcher-list '' '+m:{[:lower:]}={[:upper:]} r:|[._-]=** r:|=**' '+l:|=* r:|=*'
151zstyle ':completion:*' max-errors 0 numeric
152zstyle ':completion:*' original true
153zstyle ':completion:*' verbose false
154zstyle ':completion:*:*:git*:*' verbose true
155
818cdbb4
MW
156## Initialize the fancy completion machinery.
157autoload -Uz compinit
158compinit
159
a797cf50
MW
160_r () { words[1]=sudo; _normal; }
161compdef _r rootly
162compdef _ssh @
163
164###--------------------------------------------------------------------------
165### Other shell tweaking.
166
a797cf50
MW
167unsetopt auto_cd
168unsetopt auto_menu
cba93353 169setopt bang_hist
a797cf50
MW
170unsetopt bash_auto_list
171unsetopt beep
d90fb841 172setopt c_bases octal_zeroes
a797cf50 173setopt extendedglob
f00452f2 174unsetopt flow_control
f911124e 175unsetopt global_export
f8927ad9 176setopt glob_star_short
e3c70a77 177setopt hist_ignore_all_dups
68d1e406 178setopt hist_ignore_space
cfcfc91b 179unsetopt ksh_glob
a797cf50
MW
180setopt list_ambiguous
181setopt list_packed
043b866b 182setopt multios
a797cf50
MW
183unsetopt nomatch
184unsetopt menu_complete
185setopt notify
043b866b 186setopt rc_expand_param
e3c70a77 187setopt share_history
a797cf50 188
21ba66ed
MW
189hash -d t=$TMPDIR
190
a797cf50
MW
191###--------------------------------------------------------------------------
192### Finishing touches.
193
e22144cd 194## Local tweaks.
a797cf50
MW
195__mdw_source_if_exists "$HOME/.zshrc-local"
196
197###----- That's all, folks --------------------------------------------------