-
Notifications
You must be signed in to change notification settings - Fork 20
/
.commonrc
313 lines (263 loc) · 8.56 KB
/
.commonrc
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
# shellcheck shell=bash
# Ignore source location info
SHELLCHECK_OPTS+=" -e SC1090"
export SHELLCHECK_OPTS
source ~/.commonfuncs
# what freakin' linux is this?
alias what_linux="cat /etc/issue"
# switch over to the simple prompt
alias sp='source ~/.zshprompt_simple'
# prefer vim over vi
if checkPath nvim; then
alias vi=nvim
alias vim=nvim
elif checkPath vim; then
alias vi=vim
else
# keep me honest
alias vim=vi
fi
# use gvim or mvim for either command
checkPath gvim && alias mvim=gvim
checkPath mvim && alias gvim=mvim
alias v=vim
# Open vim with nerdtree open
alias vn="vim -c ':NERDTree | wincmd l'"
# use gitx with "all branches"
alias gitxa="gitx --all"
# use git-achievements if it is avaiable
if checkPath git-achievements; then
alias git=git-achievements
fi
# Can't break the os x habit
if checkPath spd-say; then
alias say=spd-say
fi
# some OS X specific stuff
if [ "$(uname)" = "Darwin" ]; then
os_majorversion=$(sw_vers | awk '/ProductVersion/ {print $2}' | cut -f1 -d'.' | head -n 1)
# set up a path in .profile for TextMate (zsh haterz)
# NOTE: this will overwrite the .profile
echo "export PATH=$PATH" > ~/.profile
# Quickly re-enable refit
alias refi=/efi/refit/enable.sh
if checkPath mysql5; then
# I have mysql5 installed with MacPorts, which adds the 5
alias mysql='mysql5'
fi
# For OS X >= 10.8, you'll need the EnvPane pref pane
# http://diaryproducts.net/EnvPane
# OR
# https://stackoverflow.com/questions/603785/environment-variables-in-mac-os-x/4567308#4567308
if [ "$os_majorversion" -le 7 ]; then
if checkPath defaults; then
# also set up the osx path
# (this will overwrite the PATH everytime we open a shell)
defaults write ~/.MacOSX/environment PATH -string "$PATH"
fi
fi
# add ports into the $MANPATH
export MANPATH=/opt/local/man:$MANPATH
fi
# grepping (or acking)
# sgrep stands for super grep, meaning recursive and case insensitive
if checkPath pt; then
alias sgrep=pt
elif checkPath ag; then
alias sgrep=ag
elif checkPath ack; then
alias sgrep=ack
elif checkPath ack-grep; then
alias sgrep=ack-grep
else
# using the GNU grep trunk with the exclude dir opt
#alias grep='grep -EIn --exclude-dir=".svn" --exclude-dir="CVS" --exclude=".DS_STORE" --exclude="*pyc" --color=always'
alias sgrep='grep -EIn --exclude=".DS_STORE" --exclude="*pyc" --color=always'
alias sgrep='grep -ir'
fi
# Use gojq if it's available
if checkPath gojq; then
alias jq='gojq -L.'
fi
alias jqr="jq -r"
## ctags
alias ctags='ctags --exclude=node_modules'
## processes
alias psa='ps axwww'
alias psau='psa -u'
# pipe into grep to find a proc
alias psg='psa | grep -i'
# search for python procs
alias ispy='psg "[p]ython"'
# search for ruby procs
alias isrb='psg "[r]uby"'
# supervisor in buildouts
alias bsctl=bin/supervisorctl
# system wide supervisor
if checkPath supervisorctl; then
alias sctl=supervisorctl
fi
alias lsofp="sudo lsof -p"
# find aliases
alias delpyc="find . -name '*.pyc' -delete"
alias brokensymlinks="find -L . -type l"
# svn helpers
alias svnps="svn propset svn:externals -F EXTERNALS.txt ."
alias svnpsi="svn propset svn:ignore -F IGNORE.txt ."
# zope runs most QA/Staging instances...
alias zu='sudo -H -u zope'
alias ku='sudo -H -u karl'
# buildout...
alias bbn='bin/buildout'
alias bbN='bin/buildout -N'
alias bbc="rm -rf parts develop-eggs fake-eggs .installed.cfg"
# mr.developer shortcuts
alias bd="bin/develop"
alias bdu="bd up -v"
alias bds="bd st -v"
# creating the buildout.cfg
if [ "$(uname)" = "FreeBSD" ]; then
alias bcl='cp profiles/buildout.cfg.tmpl buildout.cfg && sed -I "" -e "s/#\( profiles\/local\.cfg\)/\1/" buildout.cfg'
else
alias bcl='cp profiles/buildout.cfg.tmpl buildout.cfg && sed -i "" -e "s/#\( profiles\/local\.cfg\)/\1/" buildout.cfg'
fi
# docker
alias d='docker'
alias dco='docker compose'
alias dcorm='dco down --remove-orphans --volumes'
# terraform
alias tf='terraform'
alias tfc='terraform console'
alias tff='terraform fmt -recursive'
alias tfi='terraform init'
alias tfiu='terraform init -upgrade && terraform providers lock -platform=linux_amd64 -platform=darwin_amd64'
alias tfs='terraform show -no-color'
alias tfp='terraform plan'
alias tfip='terraform init && terraform plan'
alias tfa='terraform apply'
alias tfpo='terraform plan --out=tfplan'
alias tfap='terraform apply tfplan'
# aws vault
alias ave='aws-vault exec work --'
alias aveh='aws-vault exec home --'
# pep8 that can scan a `src` dir
alias pep8scan="pep8 --repeat --show-source --statistics --exclude='paste,*PasteDeploy*,bootstrap.py'"
# Ruby and rvm stuff
alias ru='rvm use'
alias rud='ru default@tb'
alias rum='ru default@mailcatcher'
# rbenv
alias re='rbenv exec'
# bundler
alias be='bundle exec'
# Vagrant ssh commands
alias vssh="vagrant ssh"
vs() {
vagrant ssh -c "cd /vagrant && $*"
}
vsbe() {
vagrant ssh -c "cd /vagrant && bundle exec $*"
}
# make cp and move ask before replacing files
alias cp='cp -iv'
alias mv='mv -i'
if checkPath eza; then
alias ls='eza'
alias ll='ls -lag'
alias lsa=ll
alias lss='ll --reverse --sort=size'
alias lsdate='ll --sort=modified'
alias lsd='lsa -d'
alias lsdot='lsd .*'
else
# Use colors and filetype characters with ls by default
# conditionally setting up coloring on different OS types
case $(uname) in
FreeBSD|Darwin) alias ls='ls -FG' ;;
Linux) alias ls='ls -F --color=auto' ;;
SunOS) alias ls='ls -F --color=always' ;;
esac
# show me all files (long list)
alias ll='ls -al'
# show me everything human readable
alias lsa='ll -h'
# sort by size
alias lss='lsa -Sr'
# sort by date modified
alias lsdate='lsa -tr'
# don't list directories
alias lsd='lsa -d'
# list all dot files
alias lsdot='lsd .*'
fi
alias df='df -h'
# tar aliases. ignore OS X meta files
alias targzc='tar --exclude=".DS_Store" --exclude="*pyc" -zcvf'
alias tarbzc='tar --exclude=".DS_Store" --exclude="*pyc" -jcvf'
alias targzx='tar -zxvf'
alias tarbzx='tar -xvjf'
# 7zip
alias 7zultra='7za a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on'
# always show all versions of an executable
alias wha="which -a"
alias whicha="which -a"
# Always set TERM to avoid missing 'tmux'
alias ssh="TERM=screen-256color ssh"
# ssh over a slow connection
alias sshc="ssh -C -c blowfish"
# get my external ip address
alias whatsmyip="curl ipinfo.io/ip; echo"
# can't break the OS X habit :)
if checkPath open; then
true
elif checkPath rifle; then
# Use Ranger's Rifle
alias open=rifle
elif checkPath gnome-open; then
# Use Gnome's opener
alias open=gnome-open
elif checkPath xdg-open; then
# Use the X opener
alias open=xdg-open
fi
# Shortened commands
alias g=git
alias s=svn
# Tmux shortcuts, use wemux if available
if checkPath wemux; then
alias t=wemux
else
alias t=tmux
alias ta='t attach -t '
alias tn='t new-session -s '
fi
# Virtualenv/wrapper stuff
alias w=workon
alias mkv=mkvirtualenv
alias cds=cdsitepackages
# Lastpass
alias lpcp="lpass ls -l | fzf | sed -Ee 's/.*\[id\: ([0-9]+)\]/\1/' | xargs lpass show -c --password"
alias lpcpu="lpass ls -l | fzf | sed -Ee 's/.*\[id\: ([0-9]+)\]/\1/' | xargs lpass show -c --username"
if checkPath vivid; then
export LS_COLORS=$(vivid generate catppuccin-latte)
else
# Pretty LS_COLORS explanation:
# http://www.mjxg.com/index.py/geek/lscolors_and_ls_colors
export LS_COLORS="no=00:fi=00:di=32:ln=36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=31:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:"
fi
VIRTUALENVS_DIR=$HOME/.virtualenvs
VIRTUALENVWRAPPER_PYTHON=`which python3`
# if the virutalenv wrapper is available, then source it
if [ -d "$VIRTUALENVS_DIR" ]; then
export WORKON_HOME=$VIRTUALENVS_DIR
if [ -e /usr/share/virtualenvwrapper/virtualenvwrapper.sh ]; then
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
elif checkPath virtualenvwrapper_bashrc; then
source virtualenvwrapper_bashrc
elif checkPath virtualenvwrapper.sh; then
source virtualenvwrapper.sh
fi
fi
# Tmuxinator setup
[[ -s ~/.tmuxinator/scripts/tmuxinator ]] && source ~/.tmuxinator/scripts/tmuxinator
[ -f '/usr/local/opt/asdf/libexec/asdf.sh' ] && source /usr/local/opt/asdf/libexec/asdf.sh