-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zprofile
189 lines (167 loc) · 5.89 KB
/
.zprofile
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
eval "$(/opt/homebrew/bin/brew shellenv)"
eval "$(rbenv init - zsh)"
# Use vim key bindings.
set -o vi
# Allow use of Ctrl+R to reverse-search through commands
bindkey -v
bindkey '^R' history-incremental-search-backward
# Android development
[ -d "$HOME/Library/Android/sdk" ] && ANDROID_HOME=$HOME/Library/Android/sdk || ANDROID_HOME=$HOME/Android/Sdk
echo "export ANDROID_HOME=$ANDROID_HOME" >> ~/`[[ $SHELL == *"zsh" ]] && echo '.zshenv' || echo '.bash_profile'`
echo "export PATH=$ANDROID_HOME/platform-tools:\$PATH" >> ~/`[[ $SHELL == *"zsh" ]] && echo '.zshenv' || echo '.bash_profile'`
export EDITOR=/opt/homebrew/bin/vim # Use vim as the default editor.
export PATH="/usr/local/heroku/bin:$PATH" # Added by the Heroku Toolbelt
export PATH="./node_modules/.bin:$PATH" # Make node executables in the current node project accessible
export PATH="/opt/homebrew/Cellar/[email protected]/3.11.2_1/libexec/bin:$PATH" # Make python executable (only `python3` is available by default from `brew install python`)
export PS1="\W$ " # Format the bash prompt to only show the current directory
export PS2="> " # Format the continuation interactive prompt
export RAILS_ENV=development
export VISUAL="$EDITOR"
# Set up thefuck (https://github.com/nvbn/thefuck)
eval $(thefuck --alias)
# Set up NVM
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
# pnpm
export PNPM_HOME="/Users/jessepinho/Library/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
alias android-emulator='~/Library/Android/sdk/tools/emulator -avd pixel2 &'
alias be='bundle exec'
alias dotfiles='cd ~/.dotfiles'
alias dr80='docker run -p 80:80'
# https://remysharp.com/2017/05/29/getting-free-wifi
alias freewifi="sudo ifconfig en0 ether `openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`"
alias g='git'
alias gc='git commit'
alias gcm='gc -m '
alias gcp='gc && gpoh'
alias gpoh='git push origin head'
alias gpohnv='git push origin head --no-verify'
alias gpohf='git push origin head --force'
alias gpohfnv='git push origin head --force --no-verify'
alias gpohu='git push origin head -u'
alias gpohunv='git push origin head -u --no-verify'
alias ll='ls -alh'
alias ntw='npm test -- --watch'
alias ntws='npm test -- --watch --silent'
alias szp='source ~/.zprofile'
alias simplehttpserver='python -m SimpleHTTPServer 8000'
alias untar='tar -xvzf'
alias vzp='vim ~/.zprofile'
# Copied over from old .bash_profile. Not sure what it's for, so commenting it
# out for now.
# ulimit -n 4096
checkPort() {
lsof -i tcp:$1
}
# Switch iTerm profile. Thanks to http://superuser.com/a/948104/286156
iterm() {
local message="Changing iTerm profile to $1."
echo -e "$message\033]50;SetProfile=$1\a"
}
# Include a local version of .zprofile, if it exists.
if [ -f ~/.zprofile_local ]; then
source ~/.zprofile_local
fi
# Prune merged branches. Thanks to http://stackoverflow.com/a/6127884/974981
function gpm {
git branch --merged \
| grep -v "\*" \
| grep -v master \
| xargs -n 1 git branch -d
git remote prune origin
}
function setUpCodeDirectoryAliases {
local file
# Iterate over all files in ~/Code
for file in ~/Code/*; do
# Filter for just directories
if [ -d $file ]; then
# Get the directory name without the full path
local aliasName=$(basename $file)
# Make sure the directory's name isn't already a command in bash
if ! command -v $aliasName >/dev/null 2>&1; then
# Create an alias named after the directory that cd's into it
alias $aliasName="cd $file"
fi
fi
done
}
setUpCodeDirectoryAliases
function setUpWorkDirectoryAliases {
local file
# Iterate over all files in ~/Code
for file in ~/Code/work/*; do
# Filter for just directories
if [ -d $file ]; then
# Get the directory name without the full path
local aliasName=$(basename $file)
# Make sure the directory's name isn't already a command in bash
if ! command -v $aliasName >/dev/null 2>&1; then
# Create an alias named after the directory that cd's into it
alias $aliasName="cd $file"
fi
fi
done
}
setUpWorkDirectoryAliases
###-begin-npm-completion-###
#
# npm command completion script
#
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc)
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
#
if type complete &>/dev/null; then
_npm_completion () {
local words cword
if type _get_comp_words_by_ref &>/dev/null; then
_get_comp_words_by_ref -n = -n @ -w words -i cword
else
cword="$COMP_CWORD"
words=("${COMP_WORDS[@]}")
fi
local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
complete -o default -F _npm_completion npm
elif type compdef &>/dev/null; then
_npm_completion() {
local si=$IFS
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
COMP_LINE=$BUFFER \
COMP_POINT=0 \
npm completion -- "${words[@]}" \
2>/dev/null)
IFS=$si
}
compdef _npm_completion npm
elif type compctl &>/dev/null; then
_npm_completion () {
local cword line point words si
read -Ac words
read -cn cword
let cword-=1
read -l line
read -ln point
si="$IFS"
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
compctl -K _npm_completion npm
fi
###-end-npm-completion-###