-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
210 lines (182 loc) · 5.23 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
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
# ___ __
# /_ / ___ / / ________
# _ / /_(_-</ _ \/ __/ __/
# (_)___/___/_//_/_/ \__/
#
# Joshua Elliott
#
# TODO:
# - Move from oh-my-zsh to just antigen
# --------------------------
# colorized output
function cinfo() {
echo -e "\x1b[32m$1\x1b[0m" # green
}
function cwarn() {
echo -e "\x1b[33m$1\x1b[0m" # yellow
}
function cerror() {
echo -e "\x1b[31m$1\x1b[0m" # red
}
### antigen ###
ZSH_CUSTOM="$HOME/.zsh"
ADOTDIR="$HOME/.zsh"
source "$HOME/.zsh/plugins/antigen/antigen.zsh"
# Bundles
antigen use oh-my-zsh
ZSH_TMUX_AUTOCONNECT=false
# don't let the plugin override our TERM setting
# ZSH_TMUX_FIXTERM=false
# antigen bundle tmux
antigen bundle gitfast
antigen bundle ruby
antigen bundle python
antigen bundle golang
if [[ $platform == 'darwin' ]]; then
antigen bundle osx
antigen bundle brew
fi
antigen bundle zsh-users/zsh-syntax-highlighting
# Theme
antigen theme afowler
antigen apply
# TODO: move this to a more appropriate place
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$fg[yellow]%}"
### zsh options ###
# GLOBDOTS lets files beginning with a . be matched without explicitly specifying the dot
setopt globdots
# HISTIGNOREDUPS prevents the current line from being saved in the history if it is the same as the previous one
setopt histignoredups
# TODO: look into getting corrections working better
# CORRECT turns on spelling correction for commands
unsetopt correct
# CORRECTALL turns on spelling correction for all arguments.
unsetopt correctall
# Use vi style bindings
#bindkey -v
# use <C-space> like up arrow
bindkey '^ ' up-line-or-search
# use <C-B> instead of <C-A> (tmux prefix)
bindkey '^B' beginning-of-line
### Check OS ###
platform='unknown'
case `uname` in
Darwin)
platform='darwin'
;;
Linux)
platform='linux'
;;
esac
# Determine the specific linux distro
distro=''
if [ $platform = 'linux' ]; then
if [ -f /etc/debian_version ]; then
distro='debian'
elif [ -f /etc/arch-release ]; then
distro='arch'
else
distro='unknown'
fi
fi
cinfo "Operating System: $platform $distro"
### Path ###
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/texbin
if [ -d "$HOME/bin" ]; then
PATH=$HOME/bin:$PATH
fi
export PATH
### Term ###
# export TERM='xterm-256color'
# export TERM='xterm-16color'
### Editor ###
export EDITOR='vim -f'
### Use vim for man pager ###
function vman {
vim -MRn -c 'set ft=man nomod nolist nonumber' \
-c 'map q :q<CR>' \
-c 'map <SPACE> <C-D>' \
-c 'map b <C-U>' \
-c 'nmap K :Man <C-R>=expand(\\\"<cword>\\\")<CR><CR>' \
=(/usr/bin/man $* | col -bx)
# zsh process substitution: =(...) is replaced with the name of a file containing its output
# this is not the same as <(...) which creates a named pipe (FIFO) instead
}
# alias man='vman'
### Aliases ###
if [[ $platform == 'darwin' ]]; then
# Using GNU coreutils
alias ls='gls --color=auto'
alias ll='gls -lah --color=auto'
alias la='gls -a --color=auto'
alias ql='quick-look'
alias tmux='TERM=xterm-256color tmux -2'
elif [[ $platform == 'linux' ]]; then
alias ls='ls --color=auto'
alias ll='ls -lah --color=auto'
alias la='ls -a --color=auto'
if [[ $distro == 'arch' ]]; then
# alias tmux='tmux -2'
# alias tmux='TERMINFO=/usr/share/terminfo/x/xterm-16color TERM=xterm-16color tmux -2'
alias tmux='TERM=screen-256color-bce tmux'
fi
fi
alias df='df -h'
# alias no='ls' # for dvorak
alias vimconf='vim ~/.vimrc'
alias zshconf='vim ~/.zshrc'
# Git aliases
# TODO: move these to real git aliases?
alias gst='git status'
alias gc='git commit -v'
alias glg='git log --all --stat --graph --decorate'
alias glgo='git log --all --graph --decorate --oneline'
alias glgs='git log --all --stat --graph --decorate --max-count=3'
alias ga='git add'
alias gsa='git submodule add' # gsa <repo> <directory>
alias gsi='git submodule init'
alias gsu='git submodule update'
alias gsuu='git submodule foreach git pull origin master'
alias gcm='git checkout master'
alias gch='git checkout'
alias gcb='git checkout -b'
alias gl='git pull'
alias gs='git push'
alias gpp='git pull;git push'
alias gf='git diff'
alias gba='git branch -a'
# turn off globbing for rake commands (rake task[arg] breaks)
alias rake="noglob rake"
# Use hub (github extensions for git) if it's installed
command -v hub >/dev/null 2>&1
if [ $? -eq 0 ]; then
eval "$(hub alias -s)"
# alias git='hub'
else
cwarn "You should install hub (defunkt.io/hub)"
fi
# easy json pretty print (e.g., `curl something | json`)
alias json='python -m json.tool'
### directory colors on linux (for using solarized color scheme) ###
if [ -f "$HOME/.config/.dircolors" ]; then
#echo "using .dircolors"
if [[ $platform == 'darwin' ]]; then
eval `gdircolors $HOME/.config/.dircolors`
elif [[ $platform == 'linux' ]]; then
eval `dircolors ~/.config/.dircolors`
fi
fi
### Ruby ###
if [ -d "$HOME/.rvm" ]; then
#echo "Set up ruby stuff"
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
fi
### Local customizations ###
if [ -f "$HOME/.zshrc.local" ]; then
cinfo "loading .zshrc.local"
source "$HOME/.zshrc.local" ]
fi
### Start in home directory and Confirm load ###
# cd $HOME
cinfo "energize!"