forked from jbrodley/mac-setup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bash_profile
137 lines (118 loc) · 4.16 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
#!/bin/bash
alias accounts='cd ~/Code/aws-account-management-platform && git fetch && git pull && cd ~/Code/PublicCloud-Utilities && src/make_profile_list.py -o ~/.aws/config -f'
alias mkpasswd='openssl rand -base64 8'
alias vib="vi ~/.bash_profile"
alias vif="vi ~/.bash_functions"
alias refresh="source ~/.bash_profile;source ~/.bash_functions"
alias code='cd ~/Code'
alias accts='PREVDIR=`pwd`;cd ~/Code/aws-account-management-platform && bundle exec rake list_accounts; cd $PREVDIR'
alias cflaunch='~/Code/rlucas_scripts/cf_deploystack.sh'
alias rake='bundle exec rake'
alias findacct='aws organizations describe-account --profile em-master-prod --account-id'
alias tf='terraform'
HISTFILE=~/.bash_history
HISTSIZE=5000
HISTFILESIZE=10000
export DATE=`date +%Y%m%d_%H%M%S`
test -e "~/.iterm2_shell_integration.bash" && source "~/.iterm2_shell_integration.bash"
# guzzi specific
if [[ `hostname` == "guzzi" ]];then
eval "$(rbenv init -)"
source ~/.evident
source ~/.artifactory
fi
source ~/.bash_functions
# Copies profile and anything else in briefcase to remote hosts
BRIEFCASE=~/.briefcase
# Check to see whether we have ssh.
SSH=`type -path ssh`
if [[ -n $SSH ]]; then
HAVE_SSH=yes
__SSH=$SSH
else
unset HAVE_SSH;
fi
if [ -n "$HAVE_SSH" ]; then
function ssh()
{
# First: Determine the hostname argument.
# Skip all the command line arguments using getopts (shell builtin).
# This will set $OPTIND to the index of the first non-option argument,
# which should be the hostname argument to ssh, if provided.
# N.B.: This option list is current as of OpenSSH 4.5p1, and may need
# to be updated as newer versions are released.
sshargs="$@"
while getopts ':1246AaCfgkMNnqsTtVvXxYb:c:D:e:F:i:L:l:m:O:o:p:R:S:w:' \
Option
do
# If connecting to the remote host under a different user ID:
# don't copy the briefcase files!
case $Option in
"l") SSH_SKIP_COPY=1
;;
esac
done
shift $(($OPTIND - 1))
# We have to reset OPTIND, otherwise future invocations of this
# function will fail to properly parse the command line.
OPTIND=1
# $1 should now be either the hostname or empty
if [ -n "$SSH_SKIP_COPY" ];then
# No hostname specified, or connecting to the remote host under a different user ID:
# Run ssh as specified.
$__SSH $sshargs
else
# Copy our environment to the target host ($1)'s home directory.
# We run rsync with -u so that any newer files on the target
# host are preserved. All files to be synced to the target host
# should be listed, one per line, in $HOME/.briefcase.
rsync -uptgo -e $__SSH --files-from=$BRIEFCASE \
"$HOME" "$1":~/ || echo "Briefcase sync failed: $!" >&2
# Now run ssh, with the command line intact.
$__SSH $sshargs
fi
unset SSH_SKIP_COPY
unset ssh
}
fi
# This should do pretty things to git prompt
parse_git_branch ()
{
local GITDIR=`git rev-parse --show-toplevel 2>&1` # Get root directory of git repo
if [[ "$GITDIR" != '/root' ]] # Don't show status of home directory repo
then
# Figure out the current branch, wrap in brackets and return it
local BRANCH=`git branch --no-color 2>/dev/null | sed -n '/^\*/s/^\* //p'`
if [ -n "$BRANCH" ]; then
echo -e "[$BRANCH]"
fi
else
echo ""
fi
}
function git_color ()
{
# Get the status of the repo and chose a color accordingly
local STATUS=`git status 2>&1`
if [[ "$STATUS" == *'Not a git repository'* ]]
then
echo ""
else
if [[ "$STATUS" != *'working directory clean'* ]]
then
# red if need to commit
echo -e '\033[0;31m'
else
if [[ "$STATUS" == *'Your branch is ahead'* ]]
then
# yellow if need to push
echo -e '\033[0;33m'
else
# else cyan
echo -e '\033[0;36m'
fi
fi
fi
}
# Call the above functions inside the PS1 declaration
PS1='\[$(git_color)\]$(parse_git_branch)\[\033[01;32m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \$ '