-
Notifications
You must be signed in to change notification settings - Fork 3
/
.bash_profile
186 lines (158 loc) · 4.5 KB
/
.bash_profile
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
pw () {
read -s
echo $REPLY
unset $REPLY
}
function cd {
builtin cd "$@" && ls -Gp
}
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias grep='grep --color=auto'
alias ls='ls -Gp'
alias ping='ping -c 5'
alias rmf='rm -Rf'
alias copen='open -a Sublime\ Text\ 2'
alias vs='vim -O'
function openApp {
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app=$1
}
alias app=openApp
alias fb='app http://www.messenger.com'
alias sc='app http://www.soundcloud.com'
##################################
# git
##################################
# i need to gget my keyboard fixed
alias ggit=git
# git push upstream
alias gpup='git push -u origin $(git rev-parse --abbrev-ref HEAD)'
alias gitrev='git rev-parse --short HEAD'
prune-branches () {
BRANCHES="$(git fetch --prune --dry-run 2>&1 | grep jhh/ | sed -E 's/.*origin\/(jhh\/.+)/\1/')"
echo "branches to delete:"
echo $BRANCHES
read -p "Are you sure? " -n 1 -r
echo ''
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo ''
echo "deleting local branches..."
git branch -D $BRANCHES
echo ''
echo "pruning remote branches..."
git fetch --prune
fi
}
##################################
# env variables
export EDITOR=vim
# https://github.com/jimeh/git-aware-prompt
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
export PS1="\u@\h:\W \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
# Codi https://github.com/metakirby5/codi.vim
# Usage: codi [filetype] [filename]
codi() {
local syntax="${1:-python}"
shift
vim -c \
"let g:startify_disable_at_vimenter = 1 |\
set bt=nofile ls=0 noru nonu nornu |\
hi ColorColumn ctermbg=NONE |\
hi VertSplit ctermbg=NONE |\
hi NonText ctermfg=0 |\
Codi $syntax" "$@"
}
atob() {
echo -n $1 | base64 -D && echo ""
echo -n $1 | base64 -D | pbcopy
echo "copied to clipboard!"
}
btoa() {
echo -n $1 | base64
echo -n $1 | base64 | tr -d \\n | pbcopy
echo "copied to clipboard!"
}
# generate random pw
newpw() {
length=${1:-18}
pw="$(openssl rand -base64 $length | tr -d \\n)"
echo $pw | tr -d \\n | pbcopy
echo $pw
echo "copied to clipboard!"
}
# https://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/
compress_images() {
input_path=$1
output_path=${2:-compressed}
if [ "$#" -eq 0 ]; then
echo "usage: compress_images input_path <output_path | \"compressed\">"
echo "example: compress_images '*.png' output-path"
return 1
fi
mkdir -p $output_path
mogrify -path $output_path -filter Triangle -define filter:support=2 \
-unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 \
-define png:compression-level=9 -define png:compression-strategy=1 \
-define png:exclude-chunk=all -interlace none -colorspace sRGB \
-strip $input_path
}
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
if [ -d ~/Library/Python/3.6/bin ]
then
export PATH=$PATH:~/Library/Python/3.6/bin
fi
# pyenv: https://github.com/pyenv/pyenv#installation
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
# https://github.com/pyenv/pyenv-virtualenv
if [[ "$(which pyenv-virtualenv)" =~ "pyenv-virtualenv" ]]; then
eval "$(pyenv virtualenv-init -)"
fi
fi
# poetry, installed from https://github.com/python-poetry/poetry#installation
export PATH="$HOME/.poetry/bin:$PATH"
# XCode
if [ -d /Applications/Xcode.app/Contents/Developer/usr/bin ]
then
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
fi
# https://docs.expo.io/versions/latest/guides/genymotion.html
if [ -d /Applications/Genymotion.app/Contents/MacOS/tools ]
then
export PATH=$PATH:/Applications/Genymotion.app/Contents/MacOS/tools
fi
# Android Studio for React Native
# https://facebook.github.io/react-native/docs/getting-started
if [ -d ~/Library/Android/sdk ]
then
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
fi
# https://docs.brew.sh/Installation
if [ -d /opt/homebrew/bin ]
then
export PATH=/opt/homebrew/bin:$PATH
fi
# set default shell
export SHELL=/bin/bash
# git autocomplete
if [ -f ~/.git-completion.bash ]
then
source ~/.git-completion.bash
fi
# external conf
if [ -f ~/.external_bash_conf ]
then
source ~/.external_bash_conf
fi