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