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