-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbashrc
executable file
·141 lines (119 loc) · 3.79 KB
/
bashrc
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
# if there's a .secrets file with environment options, source it
if [ -f $HOME/.secrets ]; then
source $HOME/.secrets
fi
path_prepend ()
{
if [[ -d $1 ]] ; then
PATH=${PATH//":$1"/} #delete any instances in the middle or at the end
PATH=${PATH//"$1:"/} #delete any instances at the beginning
export PATH="$1:$PATH" #prepend to beginning
fi
}
if [[ -d ~/google-cloud-sdk/ ]] ; then
# The next line updates PATH for the Google Cloud SDK.
source ~/google-cloud-sdk/path.bash.inc
# The next line enables bash completion for gcloud.
source ~/google-cloud-sdk/completion.bash.inc
fi
path_prepend /usr/local/share/npm # for node
path_prepend /usr/local/lib # for python
path_prepend /usr/local/heroku/bin # for heroku
path_prepend $HOME/.rvm/bin # for rvm
path_prepend /Applications
path_prepend /usr/texbin
path_prepend /Applications/Postgres.app/Contents/Versions/9.3/bin
path_prepend /usr/local/bin
path_prepend $HOME/.pyenv/bin # for pyenv
# sync bash history with multiple sessions
export HISTCONTROL=ignoredups:erasedups
shopt -s histappend
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
if [ `which lesspipe.sh` ] ; then
export LESSOPEN="|lesspipe.sh %s"
fi
# ALWAYS VIM
export EDITOR=vim
if [ `which mvim` ] ; then
#export EDITOR="mvim -f --nomru -c 'au VimLeave * !open -a $TERM_PROGRAM'"
export EDITOR=`which vim`
alias vim=mvim
fi
set -o vi
# source my xmodmap
[[ -f ~/.xmodmap ]] && xmodmap ~/.xmodmap 2>/dev/null
# git bash autocomplete
BREW=`which brew`
if [[ "$BREW" && -f $( $BREW --prefix )/etc/profile.d/bash_completion.sh ]] ; then
source $( $BREW --prefix )/etc/profile.d/bash_completion.sh
elif [[ -f /etc/bash_completion ]] ; then
source /etc/bash_completion
else
echo "Can't find bash_completion"
fi
# set prompt
function short_pwd() {
echo -n $(pwd | perl -F/ -ane 'print join( "/", map { $i++ < @F - 1 ? substr $_,0,1 : $_ } @F)')
}
# set prompt to be a short-hand path with git_ps1
#export PS1="\$(short_pwd)\$(__git_ps1 | tr -d ' ')$ "
# 256 colors in tmux
alias tmux="tmux -2"
# shortcuts for tmux
alias tls="tmux list-sessions"
alias tas="tmux attach-session -t"
# reattach to previous session (if using tmux as a login shell
# if [ $"(tmux ls | grep 0: )" ]; then
# tmux switch -t 0
# tmux kill-session -a -t 0
# fi
eval "$(pyenv init -)"
# set where virutal environments will live
export WORKON_HOME=$HOME/.virtualenvs
# ensure all new environments are isolated from the site-packages directory
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
# use the same directory for virtualenvs as virtualenvwrapper
export PIP_VIRTUALENV_BASE=$WORKON_HOME
# makes pip detect an active virtualenv and install to it
export PIP_RESPECT_VIRTUALENV=true
if [[ -r /usr/local/bin/virtualenvwrapper.sh ]]; then
if [[ -z "$VIRTUAL_ENV" ]] ; then
source /usr/local/bin/virtualenvwrapper.sh
fi
fi
# spin up a new VM
new_vm() {
$CB_REPO/external/vmutils/create_vagrant_vm.py -H [email protected] -G $CB_REPO/ -v3 --distro=precise
cd $HOME/vagrant/$@
vagrant up
}
# get the server list for a type
gsl() {
$CB_REPO/external/tools/get_server_list.py $@
}
# polysh into all servers of a type
psh() {
local hosts=`gsl $1`
shift
local server
# remove the existing entries in ~/.ssh/known_hosts
for server in $hosts
do
ssh-keygen -H -R $server > /dev/null 2>&1
done
# rescan and add them to known_hosts
ssh-keyscan -H $hosts >> $HOME/.ssh/known_hosts 2> /dev/null
# ssh into them simulaneously
echo "Connecting to $hosts"
polysh $hosts $*
}
if [[ `which fortune` ]] ; then
# ,__,
# (oo)____
# (__) )\
# ||--|| *
fortune -s | cowsay $(perl -e '@a=qw/b d g p s t w y/; print q/-/, $a[int(rand(scalar @a))]')
fi
if [[ -f ~/.bashrc_local ]] ; then
source ~/.bashrc_local
fi