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