]> git.openstreetmap.org Git - chef.git/blob - cookbooks/accounts/files/default/tomh/.zshrc
Update zshrc for tomh
[chef.git] / cookbooks / accounts / files / default / tomh / .zshrc
1 # Z-shell options
2 setopt ALL_EXPORT
3 setopt AUTO_CD
4 setopt AUTO_LIST
5 setopt AUTO_MENU
6 setopt CDABLE_VARS
7 setopt CORRECT
8 setopt CORRECT_ALL
9 setopt HIST_EXPIRE_DUPS_FIRST
10 setopt HIST_IGNORE_DUPS
11 setopt HIST_NO_STORE
12 setopt HIST_REDUCE_BLANKS
13 setopt HIST_SAVE_NO_DUPS
14 setopt INC_APPEND_HISTORY
15 setopt LIST_AMBIGUOUS
16 setopt LIST_TYPES
17 setopt LONG_LIST_JOBS
18 setopt NO_BEEP
19 setopt NO_NOMATCH
20 setopt NOTIFY
21 setopt PROMPT_SUBST
22 setopt PUSHD_SILENT
23 setopt SH_WORD_SPLIT
24
25 # Disable bracketed paste mode
26 unset zle_bracketed_paste
27
28 # Keep tramp happy
29 if [[ "$TERM" = "dumb" ]]
30 then
31     unsetopt PROMPT_SP
32     unsetopt PROMPT_CR
33     unsetopt ZLE
34 fi
35
36 # Fallback to a more basic terminal type if necessary
37 if [[ -z "${terminfo[cols]}" ]]
38 then
39     case "$TERM" in
40         xterm*) TERM="xterm";;
41     esac
42 fi
43
44 # Lock the terminal
45 ttyctl -f
46
47 # Make sure we know the username
48 if [[ -z "$USER" ]]
49 then
50     USER="$(id -un)"; export USER
51 fi
52
53 # Setup a default path
54 PATH=".:${HOME}/bin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin"
55
56 # Setup a pager
57 PAGER="less"; export PAGER
58 LESS="aceiMRs"; export LESS
59
60 # Use vi for editing
61 EDITOR=/usr/bin/vi; export EDITOR
62 VISUAL=/usr/bin/vi; export VISUAL
63
64 # History setup
65 HISTFILE=$HOME/.zshhistory
66 SAVEHIST=1000
67 HISTSIZE=1500
68
69 # Ignore certain files when doing expansion
70 fignore=( \~ \# .o )
71
72 # Set the prompt
73 case "$TERM" in
74     xterm*) PROMPT="%{\e]0;\${ENVIRONMENT:+\${ENVIRONMENT} on} %M\a%}%m [%~] %# ";;
75     screen*) PROMPT="%{\ek\${ENVIRONMENT:+\${ENVIRONMENT} on} %M\e\%}%m [%~] %# ";;
76     *) PROMPT="%m [%~] %# ";;
77 esac
78
79 # Configure directory colours
80 eval "$(/usr/bin/dircolors --sh ${HOME}/.dir_colors)"
81
82 # Setup aliases
83 alias ls="ls -CFhv --color=auto"
84 alias df="df -h"
85 alias du="du -h"
86 alias grep="grep --color=auto"
87 alias egrep="egrep --color=auto"
88 alias fgrep="fgrep --color=auto"
89 alias cd="nocorrect cd"         # no spelling correction on cd
90 alias mv="nocorrect mv"         # no spelling correction on mv
91 alias cp="nocorrect cp"         # no spelling correction on cp
92 alias mkdir="nocorrect mkdir"   # no spelling correction on mkdir
93 alias man="nocorrect man"       # no spelling correction on man
94 alias pg="less"
95
96 # Select the emacs key map
97 bindkey -A emacs main
98
99 # Bind various keys - hard code xterm bindings to match linux xterms
100 case "$TERM" in
101     dumb)
102         ;;
103     xterm*)
104         bindkey "^[OA" history-beginning-search-backward
105         bindkey "^[[A" history-beginning-search-backward
106         bindkey "^[OB" history-beginning-search-forward
107         bindkey "^[[B" history-beginning-search-forward
108         bindkey "^[OH" beginning-of-line
109         bindkey "^[OF" end-of-line
110         bindkey "^[[2~" overwrite-mode
111         bindkey "^[[3~" delete-char;;
112     *)
113         bindkey "${terminfo[kcuu1]}" history-beginning-search-backward
114         bindkey "^[[A" history-beginning-search-backward
115         bindkey "${terminfo[kcud1]}" history-beginning-search-forward
116         bindkey "^[[B" history-beginning-search-forward
117         bindkey "${terminfo[khome]}" beginning-of-line
118         bindkey "${terminfo[kend]}" end-of-line
119         bindkey "${terminfo[kich1]}" overwrite-mode
120         bindkey "${terminfo[kdch1]}" delete-char;;
121 esac
122
123 # Configure completion
124 zstyle ":completion:*" completer _complete _approximate
125 zstyle ":completion:*" format "Completing %d"
126 zstyle ":completion:*" group-name ""
127 zstyle ":completion:*" menu select=long
128 zstyle ":completion:*" rehash true
129 zstyle ":completion:*" select-prompt "%SScrolling active: current selection at %p%s"
130
131 # Enable completion
132 autoload -U compinit
133 compinit
134
135 # Autoload all local functions
136 autoload ${HOME}/zshfuncs/*(:t)