chiark / gitweb /
dot/zshrc: Inhibit line editing when terminal is `dumb'.
[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
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
23if [ -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)
28fi
29
30###--------------------------------------------------------------------------
31### Line editing.
32
dbd3e351
MW
33case $TERM in dumb) unsetopt zle ;; esac
34
a797cf50
MW
35bindkey -e
36
d7b20e5c
MW
37for 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
41do
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
50done
51
52bindkey "\eb" backward-word-bash
53bindkey "\e^b" backward-word-shell
54bindkey "\ef" forward-word-bash
55bindkey "\e^f" forward-word-shell
56bindkey "\e^?" backward-kill-word-bash
57bindkey "^w" backward-kill-word-shell
58bindkey "\ed" kill-word-bash
59bindkey "\e^d" kill-word-shell
60bindkey "\et" transpose-words-bash
61bindkey "\e^t" transpose-words-shell
62bindkey "\eu" up-case-word-bash
63bindkey "\e^u" up-case-word-shell
e3674277
MW
64bindkey "\el" down-case-word-bash
65bindkey "\e^l" down-case-word-shell
d7b20e5c
MW
66bindkey "\ec" capitalize-word-bash
67bindkey "\e^c" capitalize-word-shell
68
eda14eb9
MW
69bindkey "\ep" history-beginning-search-backward
70bindkey "\en" history-beginning-search-forward
71
a897ee2c
MW
72setopt interactive_comments
73bindkey "\e#" pound-insert
74
c510f8b9
MW
75__mdw_delete_horizontal_space () {
76 LBUFFER=${LBUFFER%%[[:space:]]##}
77 RBUFFER=${RBUFFER##[[:space:]]##}
78}
79zle -N delete-horizontal-space __mdw_delete_horizontal_space
80bindkey "\e\\" delete-horizontal-space
81
82__mdw_just_one_space () {
83 LBUFFER="${LBUFFER%%[[:space:]]##} "
84 RBUFFER=${RBUFFER##[[:space:]]##}
85}
86zle -N just-one-space __mdw_just_one_space
87bindkey "\e " just-one-space
88
a797cf50
MW
89###--------------------------------------------------------------------------
90### Completion.
91
a797cf50
MW
92## Contexts: :completion:FUNCTION:COMPLETER:COMMAND:ARGUMENT:TAG
93zstyle ':completion:*' completer _expand _complete _ignored _approximate
94zstyle ':completion:*' insert-unambiguous false
95zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
96zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
97zstyle ':completion:*' matcher-list '' '+m:{[:lower:]}={[:upper:]} r:|[._-]=** r:|=**' '+l:|=* r:|=*'
98zstyle ':completion:*' max-errors 0 numeric
99zstyle ':completion:*' original true
100zstyle ':completion:*' verbose false
101zstyle ':completion:*:*:git*:*' verbose true
102
818cdbb4
MW
103## Initialize the fancy completion machinery.
104autoload -Uz compinit
105compinit
106
a797cf50
MW
107_r () { words[1]=sudo; _normal; }
108compdef _r rootly
109compdef _ssh @
110
111###--------------------------------------------------------------------------
112### Other shell tweaking.
113
114HISTFILE=~/.zsh-history
115HISTSIZE=1000
116SAVEHIST=1000
117
a797cf50
MW
118unsetopt auto_cd
119unsetopt auto_menu
120unsetopt bash_auto_list
121unsetopt beep
122setopt extendedglob
f00452f2 123unsetopt flow_control
e3c70a77 124setopt hist_ignore_all_dups
a797cf50
MW
125setopt ksh_glob
126setopt list_ambiguous
127setopt list_packed
128unsetopt nomatch
129unsetopt menu_complete
130setopt notify
e3c70a77 131setopt share_history
a797cf50
MW
132
133zshaddhistory () {
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 --------------------------------------------------