-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.zshrc.old
357 lines (276 loc) · 8.07 KB
/
.zshrc.old
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# vim: foldmethod=marker
# ~/.zshrc
# Sourced for interactive shells only
# Environment variables {{{1
# Preload color variables
autoload colors && colors
# Unique path array
typeset -U path
path=($path /usr/local/bin $HOME/bin $HOME/.python/bin)
# Basic environment
export PAGER="less"
export LESS="-R -X -M -i -S"
export EDITOR="vim"
export VISUAL="$EDITOR"
export LANG="en_US.UTF-8"
export GREP_OPTIONS="--color=auto"
export GREP_COLOR="${color[bold]};${color[yellow]}"
export EMAIL="adambyrtek@gmail.com"
# Ruby gems installed in home directory
export GEM_HOME="$HOME/.gems"
export RB_USER_INSTALL="1"
path=($path "$GEM_HOME/bin")
# Startup file for the Python interpreter
export PYTHONSTARTUP="$HOME/.pythonrc.py"
# MacPorts
if [[ $(uname) == "Darwin" && -d /opt/local ]]; then
export PATH="/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql83/bin:$PATH"
export MANPATH="/opt/local/share/man:$MANPATH"
export DISPLAY=":0.0"
fi
# Java on Mac OS X
if [[ $(uname) == "Darwin" ]]; then
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
export ANT_HOME="/Developer/Java/ant"
fi
# Aliases and public functions {{{1
alias !=history
alias ...='../..'
alias ....='../../..'
alias .....='../../../../'
alias l="${PAGER:-less}"
alias e="${EDITOR:-vim}"
alias v=view
alias g=grep
alias s=screen
alias o=open
x() { sudo -u "$USER" -i $* > /dev/null 2>&1 &! }
d() { dict $* | colorit | less }
alias psa="ps aux"
psgrep() { ps aux | grep $* }
calc() { echo $* | bc -l }
vimgrep() { vim -c "vimgrep /$1/ $*[2,-1]" -c copen }
beep() { printf "\a" }
webshare() { python -m SimpleHTTPServer $* }
trojka() { mplayer http://stream.polskieradio.pl/program3 }
radiofonia() { mplayer http://www.radiofonia.fm/radiofonia.m3u }
# Default parameters
alias dirs="dirs -v"
alias history="history -iD"
alias du="du -chs"
alias df="df -h"
alias pstree="pstree -h"
alias diff="diff -uN"
alias cdiff="colordiff -uN"
alias tree="tree -F"
alias dtrx="dtrx -v --one=here"
alias bc="bc -lq"
alias pgrep="pgrep -l"
# Emulate useful Mac OS X commands
if which xdg-open > /dev/null; then
alias open="xdg-open"
fi
if which xclip > /dev/null; then
alias pbcopy="xclip -i"
alias pbpaste="xclip -o"
fi
# Sync history from disk
alias h="fc -R"
# Get external IP
alias myip="curl ifconfig.me"
# Colorized ls
if which dircolors > /dev/null; then
eval $(dircolors -b)
fi
if [[ $(uname) == "Darwin" || $(uname) == "FreeBSD" ]]; then
# BSD has its own way
alias ls="ls -hGF"
else
alias ls="ls -hF --color=auto"
fi
alias ll="ls -l"
alias la="ls -A"
alias lla="ls -lA"
# cd lists the new directory
cd() { builtin cd $* && ls }
# Man pages displayed in vim
if which vim > /dev/null; then
man() {
/usr/bin/man $* | \
col -b | \
vim -R -c 'set ft=man nomod nolist' -
}
fi
# Ack on Debian is called ack-grep
if which ack-grep > /dev/null; then
alias ack=ack-grep
fi
# Package management for Debian
if which aptitude > /dev/null; then
alias a=aptitude
alias sa="sudo aptitude"
elif which apt-get > /dev/null; then
alias a=apt-get
alias sa="sudo apt-get"
fi
# Package management for Gentoo
if which emerge > /dev/null; then
alias em=emerge
alias sem="sudo emerge"
alias es="esearch -c"
alias eq=equery
fi
# Package management for Arch Linux
if which pacman > /dev/null; then
alias p=pacman
alias sp="sudo pacman"
fi
# Package management for MacPorts
if which port > /dev/null; then
alias p=port
alias sp="sudo port"
fi
# Global aliases
alias -g '***'='**/*'
# Zsh variables {{{1
# Autoload all local functions
fpath=(~/.zsh/functions $fpath)
autoload -U "" ~/.zsh/functions/*(N:t)
# Enable registration of hooks
typeset -ga preexec_functions
typeset -ga precmd_functions
typeset -ga chpwd_functions
# History file
HISTFILE=~/.zsh_history
# Size of internal history buffer
HISTSIZE=1000000
# Number of history lines to save
SAVEHIST=1000000
# Show as many completions as fit on the screen
LISTMAX=0
# Slash should not be treated as part of a word
WORDCHARS="${WORDCHARS:s#/#}"
# Report time for commands taking more than a minute
REPORTTIME=60
# Spelling correction prompt
SPROMPT="%{${fg_bold[red]}%}zsh: correct '%R' to '%r' [nyae]?%{${reset_color}%} "
# Zsh options {{{1
# Append to history file instantly
setopt incappendhistory
# Save timestamps in history file
setopt extendedhistory
# Ignore entries starting with space in history
setopt histignorespace
# Ignore duplicates in history
setopt histignoredups
# Safe redirections
setopt noclobber
# Don't show completion menu
setopt noautomenu
# Show list of completions
setopt autolist
# Enter directories without cd
setopt autocd
# Add every directory to the stack
setopt autopushd
# Ignore duplicates on the stack
setopt pushdignoredups
# Spelling correction
setopt correct
# No beep when showing list of completions
setopt nolistbeep
# No line editor beep at all
setopt nobeep
# Dynamic variable substitution in prompt
setopt promptsubst
# Erase the right prompt after a line is accepted
setopt transientrprompt
# Print the exit value for commands with non-zero exit status
setopt printexitvalue
# Completion {{{1
# Enable completion
autoload -U compinit && compinit
# Display message when no matches are found
zstyle ':completion:*:warnings' format "%{${fg_bold[yellow]}%}zsh: no matches for%{$reset_color%} %d"
# Colors in completion
if [[ -n $LS_COLORS ]]; then
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
fi
# Smart case matching
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# Grouping for completion types
zstyle ':completion:*:descriptions' format "%{${fg_bold[magenta]}%}= %d =%{$reset_color%}"
zstyle ':completion:*' group-name ""
# Split manual pages by sections
zstyle ':completion:*:manuals' separate-sections 'yes'
# Ignore internal zsh functions
zstyle ':completion:*:functions' ignored-patterns '_*'
# Describe all command options
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d*'
zstyle ':completion:*:options' list-separator '#'
# Process completion shows all processes with colors
zstyle ':completion:*:*:*:*:processes' force-list always
zstyle ':completion:*:*:*:*:processes' menu yes select
zstyle ':completion:*:*:*:*:processes' command 'ps -A -o pid,user,cmd'
zstyle ':completion:*:*:*:*:processes' list-colors "=(#b) #([0-9]#)*=0=${color[green]}"
# List all processes for killall
zstyle ':completion:*:processes-names' command "ps -eo cmd= | sed 's:\([^ ]*\).*:\1:;s:\(/[^ ]*/\)::;/^\[/d'"
# Cache expensive completions
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.cache/zsh
# Generic completion
compdef _gnu_generic ack-grep
# Key bindings {{{1
# Set Emacs style editing
bindkey -e
# Ctrl-Left/Right move between words
bindkey '\e[1;5D' backward-word
bindkey '\e[1;5C' forward-word
bindkey '\e[5D' backward-word
bindkey '\e[5C' forward-word
# Edit command line in external editor
autoload -U edit-command-line
zle -N edit-command-line
bindkey '\ee' edit-command-line
# Quote URLs pasted on the command line
autoload -U url-quote-magic
zle -N self-insert url-quote-magic
# Force menu selection
bindkey '\em' menu-select
# Prompt and title {{{1
# Prompt defined in a separate function
vcs_prompt
# Set screen or xterm title
title() {
# Truncate long command and join lines
t=$(print -Pn "%40>...>$1" | tr -d "\n")
case $TERM in
screen*)
# Update screen title
print -Pn "\ek$t\e\\"
;;
xterm*|rxvt)
# Update xterm window title
print -Pn "\e]0;$t\a"
;;
esac
}
# Hook run before showing prompt
precmd_functions+=precmd_title
precmd_title() { title "zsh %1~" }
# Hook run before executing command
preexec_functions+=preexec_title
preexec_title() { title "$1" }
# Extra initialization {{{1
# Enable syntax highlighting
if [[ -r ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
if [[ -r ~/.zsh/zsh-history-substring-search/zsh-history-substring-search.zsh ]]; then
source ~/.zsh/zsh-history-substring-search/zsh-history-substring-search.zsh
fi
# Enable lesspipe if present
if which lesspipe > /dev/null; then
eval $(lesspipe)
fi