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 | 8 | ###-------------------------------------------------------------------------- |
18cc7551 MW |
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 | ###-------------------------------------------------------------------------- | |
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 | ||
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 | ||
dbd3e351 MW |
46 | case $TERM in dumb) unsetopt zle ;; esac |
47 | ||
a797cf50 MW |
48 | bindkey -e |
49 | ||
d7b20e5c MW |
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 | |
e3674277 MW |
77 | bindkey "\el" down-case-word-bash |
78 | bindkey "\e^l" down-case-word-shell | |
d7b20e5c MW |
79 | bindkey "\ec" capitalize-word-bash |
80 | bindkey "\e^c" capitalize-word-shell | |
81 | ||
2a0e079f MW |
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 | ||
eda14eb9 MW |
96 | bindkey "\ep" history-beginning-search-backward |
97 | bindkey "\en" history-beginning-search-forward | |
af8517d9 MW |
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 | |
eda14eb9 | 104 | |
a897ee2c MW |
105 | setopt interactive_comments |
106 | bindkey "\e#" pound-insert | |
107 | ||
c510f8b9 MW |
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 | ||
a797cf50 MW |
122 | ###-------------------------------------------------------------------------- |
123 | ### Completion. | |
124 | ||
a797cf50 MW |
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 | ||
818cdbb4 MW |
136 | ## Initialize the fancy completion machinery. |
137 | autoload -Uz compinit | |
138 | compinit | |
139 | ||
a797cf50 MW |
140 | _r () { words[1]=sudo; _normal; } |
141 | compdef _r rootly | |
142 | compdef _ssh @ | |
143 | ||
144 | ###-------------------------------------------------------------------------- | |
145 | ### Other shell tweaking. | |
146 | ||
a797cf50 MW |
147 | unsetopt auto_cd |
148 | unsetopt auto_menu | |
cba93353 | 149 | setopt bang_hist |
a797cf50 MW |
150 | unsetopt bash_auto_list |
151 | unsetopt beep | |
d90fb841 | 152 | setopt c_bases octal_zeroes |
a797cf50 | 153 | setopt extendedglob |
f00452f2 | 154 | unsetopt flow_control |
f911124e | 155 | unsetopt global_export |
f8927ad9 | 156 | setopt glob_star_short |
e3c70a77 | 157 | setopt hist_ignore_all_dups |
68d1e406 | 158 | setopt hist_ignore_space |
cfcfc91b | 159 | unsetopt ksh_glob |
a797cf50 MW |
160 | setopt list_ambiguous |
161 | setopt list_packed | |
043b866b | 162 | setopt multios |
a797cf50 MW |
163 | unsetopt nomatch |
164 | unsetopt menu_complete | |
165 | setopt notify | |
043b866b | 166 | setopt rc_expand_param |
e3c70a77 | 167 | setopt share_history |
a797cf50 | 168 | |
21ba66ed MW |
169 | hash -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 -------------------------------------------------- |