/
.zshrc
130 lines (116 loc) · 3.6 KB
/
.zshrc
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
typeset -U path manpath gem_home gem_path
path=(~/.bin /usr/local/bin $path)
cdpath=(~/code $cdpath)
export EDITOR='vim'
export RUBYOPT='rubygems'
autoload -U compinit
compinit
autoload colors
colors
eval `dircolors ~/.dir_colors`
export GREP_OPTIONS='--color=auto'
export GREP_COLOR='0;32'
HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=1000
REPORTTIME=10
setopt autopushd
setopt nobeep
setopt nobgnice
setopt nohup
setopt nolistbeep
setopt localoptions
setopt localtraps
setopt promptsubst
setopt correct
setopt completeinword
setopt ignoreeof
setopt autocd
setopt extendedglob
setopt globdots
# History
setopt appendhistory
setopt incappendhistory
setopt sharehistory
setopt histverify
setopt nohistbeep
setopt extendedhistory
setopt histignorealldups
setopt histignorespace
setopt histreduceblanks
setopt histverify
if [[ -r ~/.zsh/aliases ]]; then
. ~/.zsh/aliases
fi
[ -d "$HOME/Downloads" ] && hash -d downs="$HOME/Downloads"
[ -d "$HOME/Code" ] && hash -d code="$HOME/Code"
[ -d "$HOME/Code/work" ] && hash -d work="$HOME/Code/work"
[ -d "$HOME/Desktop" ] && hash -d desk="$HOME/Desktop"
[ -d "$HOME/Documents" ] && hash -d docs="$HOME/Documents"
[ -d "$HOME/.irssi/logs" ] && hash -d irc="$HOME/.irssi/logs"
if [[ -x `which git` ]]; then
function git-branch-name () {
git branch 2> /dev/null | grep '^\*' | sed 's/^\*\ //'
}
function git-dirty () {
git status 2> /dev/null | grep "nothing to commit (working directory clean)"
echo $?
}
function gsrb () {
branch=$(git-branch-name)
git checkout master
git svn rebase
git checkout "${branch}"
git rebase master
}
function git-need-to-push() {
if pushtime=$(echo $1 | grep 'Your branch is ahead' 2> /dev/null); then
echo "↑"
fi
}
function git-prompt() {
gstatus=$(git status 2> /dev/null)
branch=$(echo $gstatus | head -1 | sed 's/^# On branch //')
dirty=$(echo $gstatus | sed 's/^#.*$//' | tail -2 | grep 'nothing to commit (working directory clean)'; echo $?)
if [[ x$branch != x ]]; then
dirty_color=$fg[green]
push_status=$(git-need-to-push $gstatus 2> /dev/null)
if [[ $dirty = 1 ]] { dirty_color=$fg[red] }
[ x$branch != x ] && echo "(%{$dirty_color%}$branch%{$reset_color%}$push_status)"
fi
}
function git-scoreboard () {
git log | grep '^Author' | sort | uniq -ci | sort -r
}
function git-track () {
branch=$(git-branch-name)
git config branch.$branch.remote origin
git config branch.$branch.merge refs/heads/$branch
echo "tracking origin/$tracking"
}
function github-init () {
git config branch.$(git-branch-name).remote origin
git config branch.$(git-branch-name).merge refs/heads/$(git-branch-name)
}
function github-url () {
git config remote.origin.url | sed -En 's/git(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\3\/\4/p'
}
# Seems to be the best OS X jump-to-github alias from http://tinyurl.com/2mtncf
function github-go () {
open $(github-url)
}
function nhgk () {
nohup gitk --all &
}
fi
export PS1='${fg[magenta]}%m${fg[white]}:${fg[cyan]}%1~${fg[white]}`git-prompt`${fg[white]}%# '
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # case insensitive completion
zstyle ':completion:*:cd:*' ignore-parents parent pwd # cd will never select the parent directory (e.g.: cd ../<TAB>)
zstyle ':completion:*' completer _expand _complete
fpath=(~/.zsh/functions $fpath)
autoload -U ~/.zsh/functions/*(:t)
bindkey -v
bindkey 'jj' vi-cmd-mode
bindkey '^A' vi-beginning-of-line
bindkey '^E' vi-end-of-line
[[ -x `which brew` && -r "`brew --prefix`/etc/grc.bashrc" ]] && source "`brew --prefix`/etc/grc.bashrc"