-
Notifications
You must be signed in to change notification settings - Fork 0
/
.common_rc
167 lines (140 loc) · 5.53 KB
/
.common_rc
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
# Profile largely built off of:
# - https://github.com/nicolashery/mac-dev-setup
# - https://github.com/gf3/dotfiles
# Add the default install locations for Homebrew and pip --user to `$PATH`
PATH=/usr/local/bin:/usr/local/opt/python/libexec/bin:$PATH
export PATH
# Add hive to our path
PATH=/opt/apache-hive-1.1.0-bin/bin:$PATH
export PATH
# Set up virtualenvwrapper
export WORKON_HOME=$HOME/Envs
source /usr/local/bin/virtualenvwrapper.sh
# Load shell dotfiles
# - ~/.path can be used to extend `$PATH`
# - ~/.extra can be used for other settings you don’t want to commit
# Note: only appears that `exports` is necessary here
for file in ~/.{path,exports,functions,extra}; do
[ -r "$file" ] && source "$file"
done
unset file
# If holder for sensitive items exists, source it
if [[ -e $HOME/.bash_sensitive ]] ; then
source ~/.bash_sensitive
fi
# Set up Cmd + back arrow / forward arrow by going to:
# Go to iTerm2 > Preferences > Profiles > <your_profile > Keys # Click the + button
# Enter the key combination Cmd+←
# For the action, choose ‘Send Escape Sequence’ and enter b
# Repeat with the key combination Cmd+→ and the escape sequence f
# Color scheme for terminal comes from https://github.com/mbadolato/iTerm2-Color-Schemes/blob/master/schemes/Zenburn.itermcolors
# Set grep to highlight found patterns
export GREP_OPTIONS='--color=always'
# Create shortcuts
export BI=$HOME/repos/business-intelligence/
export BII=$HOME/repos/business-intelligence/pybi/scripts
export DT=$HOME/repos/dotfiles
export A=$HOME/repos/ansible
export P=$HOME/repos/pyline
export POWERLINE_REPO=~/Library/Python/2.7/lib/python/site-packages/powerline
export KUBE_EDITOR=vim
# Set up Cmd + back arrow / forward arrow by going to:
# Go to iTerm2 > Preferences > Profiles > <your_profile > Keys # Click the + button
# Enter the key combination Cmd+←
# For the action, choose ‘Send Escape Sequence’ and enter b
# Repeat with the key combination Cmd+→ and the escape sequence f
# Color scheme for terminal comes from https://github.com/mbadolato/iTerm2-Color-Schemes/blob/master/schemes/Zenburn.itermcolors
# Set grep to highlight found patterns
export GREP_OPTIONS='--color=always'
# Create shortcuts
export BI=$HOME/repos/business-intelligence/
export BII=$HOME/repos/business-intelligence/pybi/scripts
export DT=$HOME/repos/dotfiles
export A=$HOME/repos/ansible
export P=$HOME/repos/pyline
export POWERLINE_REPO=~/Library/Python/2.7/lib/python/site-packages/powerline
export KUBE_EDITOR=vim
# Stop kubernetes cluster info from showing up by default
export RENDER_POWERLINE_KUBERNETES=NO
export ANSIBLE_VAULT_PASSWORD_FILE=~/.ansible-vault-pw
export TILLER_NAMESPACE=analytics
alias v=/usr/local/bin/vim
alias k=kubectl
alias mktmpenv='mktmpenv -n'
# Always use color output for `ls`
alias ls='ls -lG'
alias lsa='ls -laG'
alias beehive="beeline -n $(whoami) -u 'jdbc:hive2://$HIVE_URI:10000'"
# Create shortcuts for git
alias g='git'
alias gs='git status'
alias gpl='git pull'
alias gps='git push'
alias glo='git log HEAD --not master'
gdi() { git diff $*; }
ga() { git add $*; }
gc() { git commit $*; }
gch() { git checkout $*; }
gbr() { git branch $*; }
gcd() {
local cdup=$(git rev-parse --show-cdup);
if [[ $cdup ]] ; then
cd "$cdup"
fi
}
# Set upstream quickly; better just to do gch -bt
# to automatically set up tracking though
gbrsu () {
local branch_name=$(git rev-parse --abbrev-ref HEAD);
git branch --set-upstream-to=origin/$branch_name $branch_name;
}
tma() { tmux attach -t $1; }
tmn() { tmux new -s $1; }
tmls () { tmux ls; }
docker-ip() { docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$@"; }
alias docker-rmi='docker rmi $(docker images -f "dangling=true" -q)'
alias docker-rmv='docker volume rm $(docker volume ls -f dangling=true -q)'
ksetnsp() { kubectl config set-context $(kubectl config current-context) --namespace=$1; }
kshow() {
if [[ $RENDER_POWERLINE_KUBERNETES = "NO" ]]; then
export RENDER_POWERLINE_KUBERNETES=YES
else
export RENDER_POWERLINE_KUBERNETES=NO
fi
}
# Adding this here as I always forget how to install the current kernel into my
# current virtualenv
ipy-kernel-install() {
if [[ -z $(pip show ipython) ]] ; then
echo 'ERROR: You must have the ipython library installed'
return
fi
if [[ -z $(pip show jupyter) ]] ; then
echo 'ERROR: You must have the jupyter library installed'
return
fi
ipython kernel install;
}
open_repo() {
local host_platform=$(git remote get-url origin | cut -d '@' -f 2 | cut -d '.' -f 1)
local relative_path=$(git rev-parse --show-prefix);
if [[ $host_platform = *"github"* ]]; then
local repo_name=$(git remote get-url origin | cut -d '@' -f 2 | tr : / | cut -d '.' -f 1,2);
local branch=$(cat `git rev-parse --show-cdup`.git/HEAD | cut -d '/' -f 3-)
if [[ -z $relative_path && -z $1 ]]; then
local url="https://$repo_name/tree/$branch";
else
local url="https://$repo_name/blob/$branch/$relative_path$1";
fi
else
local repo_name=$(basename `git rev-parse --show-toplevel`);
local branch=$(cat `git rev-parse --show-cdup`.git/HEAD | cut -d' ' -f2 | sed 's#/#%2F#g')
case $repo_name in
"ansible") local project=SYSTEMS;;
"dconn"|"easel"|"gsheets"|"analytics-dqis") local project=STRAT;;
*) local project=DATA;;
esac;
local url="$BASE_STASH_URL/projects/$project/repos/$repo_name/browse/$relative_path$1?at=$branch";
fi
open "$url";
}