forked from eharmon/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc.local
201 lines (169 loc) · 5.54 KB
/
zshrc.local
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#### Prompt Setup
# Shut off prompt themes, we're not ready for them yet
prompt off
# Set prompt
PROMPT='[ %F{34}%(!.%F{red}.)%n@%B%m%b%(!.%f.) ]:%U%~%u%(!.#.$) '
# Set rprompt error string
RPROMPT='%(?..[ %F{red}%?%f ])'
#### Includes
# Include hostname-specific magic if it exists
DOMAIN=`hostname | sed -E 's/^(.*\.)(!?.*\..*)$/\2/'`
if [ -e ~/.zshrc.$DOMAIN ]
then
echo "Setting shell for $DOMAIN domain"
source ~/.zshrc.$DOMAIN
fi
# Some bits to support extra features with multiplexors (screen/tmux), if available
if [[ -e ~/.zsh/zshrc.local.multiplexed ]]
then
source ~/.zsh/zshrc.local.multiplexed
fi
#### Functions
# Title command which properly supports screen, overriding grml version
title_precmd() {
# update VCS information
(( ${+functions[vcs_info]} )) && vcs_info
if [[ $TERM == screen* ]] ; then
if [[ -n ${vcs_info_msg_1_} ]] ; then
ESC_print ${vcs_info_msg_1_}
else
ESC_print "zsh"
fi
fi
# adjust title of xterm
# see http://www.faqs.org/docs/Linux-mini/Xterm-Title.html
case $TERM in
(xterm*|rxvt*|screen*)
set_title ${(%):-"%n@%m: %~"}
;;
esac
}
# title command which properly support screen, overriding grml version
title_preexec () {
# set hostname if not running on host with name 'grml'
if [[ -n "$HOSTNAME" ]] && [[ "$HOSTNAME" != $(hostname) ]] ; then
NAME="@$HOSTNAME"
fi
# get the name of the program currently running and hostname of local machine
# set screen window title if running in a screen
if [[ "$TERM" == screen* ]] ; then
# local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} # don't use hostname
local CMD="${1[(wr)^(*=*|sudo|ssh|-*)]}$NAME" # use hostname
ESC_print ${CMD}
fi
# adjust title of xterm
[[ ${NOTITLE} -gt 0 ]] && return 0
case $TERM in
(xterm*|rxvt*|screen*)
set_title "${(%):-"%n@%m:"}" "$1"
;;
esac
}
# Install precmd and preexec functions on the stack
typeset -ga precmd_functions
typeset -ga preexec_functions
precmd_functions+='title_precmd'
preexec_functions+='title_preexec'
# zsh has native support directory substitution, but this gives us even more power
scd() {
if [ -n "$1" ]; then
cd `echo $PWD | sed "$1"`
else
echo "Give me a substitution!"
fi
}
#### Aliases
# Quick alias to make an HTTP server wherever we are
alias tmphttp="python -m SimpleHTTPServer 8000"
# Give us 'wget' on machines which only have curl
if [[ $+commands[wget] -eq 0 && $+commands[curl] -eq 1 ]]
then
alias wget="curl -O -L"
fi
# Make it easier to type weechat
if [[ $+commands[weechat-curses] -eq 1 ]]
then
alias weechat="weechat-curses"
fi
# dos2unix if it isn't on the system
if [[ $+commands[dos2unix] -eq 0 ]]
then
alias dos2unix="perl -pi -e 's/\r\n|\n|\r/\n/g'"
fi
# And unix2dos
if [[ $+commands[unix2dos] -eq 0 ]]
then
alias unix2dos="perl -pi -e 's/\r\n|\n|\r/\r\n/g'"
fi
# Cat plists, binary or otherwise
if [[ $+commands[plutil] -eq 1 ]]
then
alias plcat="plutil -convert xml1 -o -"
fi
# Faster search with Spotlight
if [[ $+commands[mdfind] -eq 1 ]]
then
alias search=mdfind -onlyin
fi
alias svim=sudoedit
source ~/.zshrc.priv
#### Misc
# Use fancy history locking
is-at-least 4.3.7 && setopt HIST_FCNTL_LOCK
# Keep our auth_sock up to date. This works in tandem with a script in .ssh/rc
# which keeps the symlink updated every time we ssh again. If its set a symlink
# for us, let's pick that up
hostname=`hostname -s`
SOCK=$HOME/.cache/ssh_auth_sock_$hostname
if [ -e $SOCK ]
then
export SSH_AUTH_SOCK=$SOCK
fi
if [ `uname` == 'Darwin' ]
then
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
fi
# Set the lang, which we have to do now for some reason
export LANG=en_US.UTF-8
# Blue on black is impossible to see, change ls highlighting colors
# grml zshrc already does this for GNU userland, but not BSD
export LSCOLORS="gxfxcxdxbxegedabagacad"
#### Syntax highlighting
# Setup plugins to load
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
# Source syntax highlighting if it exists
if [ -e ~/.zsh/modules/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]
then
source ~/.zsh/modules/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
watch=""
# Main
#ZSH_HIGHLIGHT_STYLES[default]:=none
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=124'
#ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow
ZSH_HIGHLIGHT_STYLES[alias]='fg=25'
ZSH_HIGHLIGHT_STYLES[builtin]='fg=25'
ZSH_HIGHLIGHT_STYLES[function]='fg=25'
ZSH_HIGHLIGHT_STYLES[command]='fg=25'
#ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline
#ZSH_HIGHLIGHT_STYLES[commandseparator]:=none
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=25'
#ZSH_HIGHLIGHT_STYLES[path]:=underline
ZSH_HIGHLIGHT_STYLES[globbing]='fg=28'
ZSH_HIGHLIGHT_STYLES[history-expansion]='fg=25'
#ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none
#ZSH_HIGHLIGHT_STYLES[double-hyphen-option]:=none
#ZSH_HIGHLIGHT_STYLES[back-quoted-argument]:=none
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=250'
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=250'
#ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan
#ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan
#ZSH_HIGHLIGHT_STYLES[assign]:=none
# Brackets
ZSH_HIGHLIGHT_STYLES[bracket-error]='fg=160,bold'
ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=28,bold'
ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=cyan,bold'
#ZSH_HIGHLIGHT_STYLES[bracket-level-3]:=fg=magenta,bold}
#ZSH_HIGHLIGHT_STYLES[bracket-level-4]:=fg=yellow,bold}
ZSH_HIGHLIGHT_STYLES[bracket-level-5]='fg=25,bold'
#ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]:=standout}