-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdot-profile
More file actions
executable file
·265 lines (227 loc) · 7.59 KB
/
Copy pathdot-profile
File metadata and controls
executable file
·265 lines (227 loc) · 7.59 KB
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
#
# aliases
#
alias editprofile='"code" --wait -w ~/.profile; . ~/.profile'
alias o='open .'
alias n='npm'
alias s='code .'
alias m='code .'
alias c='code .'
alias bj='bundle install -j8'
alias difflast='git diff HEAD^ HEAD > ~/Desktop/diff.diff'
alias gdiff='git diff --no-index --color'
alias g='amp git'
alias copy='pbcopy'
alias paste='pbpaste'
alias todos='git grep -in todo'
alias prettyjson='paste | json | copy'
alias uglyjs='paste | uglifyjs - | copy'
alias prettycss='paste | css-beautify -f - | copy'
alias sl='ls -p'
alias ls='ls -p'
alias logs='heroku logs -n 10000 --tail'
alias k='kubectl'
# Autocomplete for 'g' alias as well
# complete -o default -o nospace -F git g
# for fast multiple terminal navigation to same dir
alias mark='pwd | pbcopy'
alias goo='cd `pbpaste`'
alias ql='qlmanage -p 2>/dev/null' # quicklook via terminal
umask 002 # prevent permissions problems
export JOBS=4 # for faster node building
export HISTCONTROL=ignoredups
export HISTSIZE=10000000
export HISTFILESIZE=10000000
export EDITOR='code -w'
export EDITOR='code -w'
export PAGER="less"
export CLICOLOR="yes"
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
export PROMPT_COLOR='1;1;40m'
# default prompt
# export PS1="\h:\W \u\$ "
parse_git_branch() {
$(which git) branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# ~/dev/dotfiles(my-branch-name)§
export PS1="\w\[\e[0;33;49m\]\$(parse_git_branch)\[\e[0;0m\]\[\e[0;32m\]§\[\e[0m\] "
shopt -s checkwinsize cdspell
# for convenience of not typing branch names 24/7
gb() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
# opens the github page for the current repo, written by @kurisuchan
function gh() {
open `git remote -v | grep hub | grep fetch | awk '{print $2}' | sed 's/git@/http:\/\//' | sed 's/com:/com\//' | sed 's/\.git//' | head -n1`
}
# for ghe, by david reiman
function ghe() {
git remote -v | awk '{ print $2 }' | sed 's/\.git//' | head -n 1 | xargs open
# open `git remote -v | node -pe "require('fs').readFileSync('/dev/stdin').toString().split('\t')[2].split(' ')[0].replace('.git', '')"`
}
function prstable() { # by David Trejo
# same as gh but without the "open"
githubUrl=`git remote -v | grep hub | grep fetch | awk '{print $2}' | sed 's/git@/http:\/\//' | sed 's/com:/com\//' | sed 's/\.git//' | head -n1`
# same as gb()
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
open "$githubUrl/compare/stable...$branch?expand=1"
}
function prdevelop() { # by David Trejo
# same as gh but without the "open"
githubUrl=`git remote -v | grep hub | grep fetch | awk '{print $2}' | sed 's/git@/http:\/\//' | sed 's/com:/com\//' | sed 's/\.git//' | head -n1`
# same as gb()
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
open "$githubUrl/compare/develop...$branch?expand=1"
}
# rm does move to trash
# via http://blog.vicshih.com/2008/04/move-to-trash-from-mac-command-line.html
function del() {
while [ -n "$1" ]; do
if [ ! -e "$1" ]; then
echo "'$1' not found; exiting"
return
fi
local file=`basename -- "$1"`
# Chop trailing '/' if there
file=${file%/}
local destination=''
if [ -e "$HOME/.Trash/$file" ]; then
# Extract file and extension
local ext=`expr "$file" : ".*\(\.[^\.]*\)$"`
local base=${file%$ext}
# Add a space between base and timestamp
test -n "$base" && base="$base "
destination="/$base`date +%H-%M-%S`_$RANDOM$ext"
fi
echo "Moving '$1' to '$HOME/.Trash$destination'"
\mv -i -- "$1" "$HOME/.Trash$destination" || return
shift
done
}
# only add to mac, in a fragile way.
if [[ "$OSTYPE" == 'darwin10.0' ]]; then
alias rm='del'
fi
if [[ "$OSTYPE" == 'darwin11' ]]; then # also lion
alias rm='del'
fi
if [[ "$OSTYPE" == 'darwin12' ]]; then # also mountain lion
alias rm='del'
fi
if [[ "$OSTYPE" == 'darwin13' ]]; then # also mavericks
alias rm='del'
fi
if [[ "$OSTYPE" == 'darwin16' ]]; then # sierra
alias rm='del'
fi
if [[ "$OSTYPE" == 'darwin17' ]]; then # high sierra
alias rm='del'
fi
if [[ "$OSTYPE" == 'darwin18' ]]; then # mojave
alias rm='del'
fi
if [[ "$OSTYPE" == 'darwin19' ]]; then # catalina
alias rm='del'
fi
alias pr='post-review'
alias pgstart='postgres -D /usr/local/var/postgres'
export MAVEN_OPTS="-server -Xms256m -Xmx512m"
alias zk='/Users/david/zookeeper-3.4.3/bin/zkServer.sh'
export DEV_DIR="$HOME/dev"
function d() {
cd "$DEV_DIR"/"$1"
}
export REPOS_DIR="$HOME/repos"
function r() {
cd "$REPOS_DIR"/"$1"
}
alias class='cd ~/Dropbox/classes'
alias desktop='$HOME/Desktop'
alias ..='cd ..'
alias ...='cd ../../'
# raise the number of files a process is allowed to have open.
ulimit -S -n 5000
#
# pull in private things or things only applicable to this machine
#
source ~/.private
# add git extensions/scripts to path
export PATH=$PATH:$HOME/bin
# add mactex scripts
export PATH=$PATH:/usr/texbin
# fix problem with tmux
export TERM=xterm-color
# makes it easy to find the main js file for any node package:
# nresolve mypackage
nresolve () {
node -p 'require.resolve("'$1'")'
}
#
# amp aliases! YEEE
#
#
# give me variable saving!
alias gs='amp -p "...(.*)$" git status -s'
alias gbr='amp -p " ? (?:remotes\\/)?(?:origin\\/)?(.*)$" git branch --sort=-committerdate' # supports -a, -r flags
alias l='CLICOLOR_FORCE=1 amp -p "(.*)" ls -1'
alias find='amp -p "(.*)" find'
alias gdiffstat='amp -p " ((?:\\/[\\w\\.\\-]+)+)" git diff --stat'
# give me variable expansion!
alias subl='amp code'
alias code='amp code'
alias ga='amp git add'
alias gap='amp git add -p'
alias grm='amp git rm'
alias gmv='amp git mv'
alias gco='amp git checkout'
alias gd='amp git diff'
alias gdh='amp git diff --staged'
alias gds='amp git diff --staged'
alias gunstage='amp git unstage'
alias gblame='amp git blame'
alias gup='amp git up' # my rebase helper script, see dtrejo/dotfiles/bin/git-up
alias gf='git fetch'
alias npx='amp npx'
alias x='amp npx'
alias cat='amp cat'
alias less='amp less'
alias gc='git commit'
alias gp='amp git push'
alias gpu='amp git push -u origin `gb`'
alias mocha='amp mocha'
alias phpfix='amp /usr/local/Cellar/php-cs-fixer/2.7.1/php-cs-fixer fix --rules=@PSR2'
# less typing
alias gamend='git amend'
alias gci="git commit"
alias guncommit='git uncommit'
# via https://stackoverflow.com/a/19135644
alias gitbranchauthors="git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n"
# Tired of writing long commands to shell into your docker image?
# Usage:
# dsh node:latest
# dsh node:latest --rm
function dsh() {
local url="$1"
[[ -z "$url" ]] && echo "Please pass a docker image url." && return 1
local args="${@:2}"
local dest="/"$(basename $PWD)
echo docker run -v $PWD:$dest -w $dest -it --entrypoint '/bin/bash' $args $url
docker run -v $PWD:$dest -w $dest -it --entrypoint '/bin/bash' $args $url \
|| docker run -v $PWD:$dest -w $dest -it --entrypoint '/bin/sh' $args $url
}
function newbranchcommit() {
git checkout -b "${$1// /-}" && git commit --allow-empty -m "$1"
}
function signwtf() {
export NUMBER=$1
export URL="https://github.com/brianleroux/wtfjs/pull/$NUMBER.patch"
curl $URL | git am --signoff
}
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
alias lock="open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app"
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion" # This loads nvm bash_completion
alias pgstart='pg_ctl -D /usr/local/var/postgres start'
alias pgkill='pg_ctl -D /usr/local/var/postgres stop'