-
Notifications
You must be signed in to change notification settings - Fork 101
/
.bash_profile
189 lines (154 loc) · 6.81 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
187
188
189
# Configuring Our Prompt
# ======================
# if you install git via homebrew, or install the bash autocompletion via homebrew, you get __git_ps1 which you can use in the PS1
# to display the git branch. it's supposedly a bit faster and cleaner than manually parsing through sed. i dont' know if you care
# enough to change it
# This function is called in your prompt to output your active git branch.
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# This function builds your prompt. It is called below
function prompt {
# Define the prompt character
local CHAR="♥"
# Define some local colors
local RED="\[\e[0;31m\]"
local BLUE="\[\e[0;34m\]"
local GREEN="\[\e[0;32m\]"
local GRAY_TEXT_BLUE_BACKGROUND="\[\e[37;44;1m\]"
# Define a variable to reset the text color
local RESET="\[\e[0m\]"
# ♥ ☆ - Keeping some cool ASCII Characters for reference
# Here is where we actually export the PS1 Variable which stores the text for your prompt
export PS1="\[\e]2;\u@\h\a[$GRAY_TEXT_BLUE_BACKGROUND\t$RESET]$RED\$(parse_git_branch) $GREEN\W\n$BLUE//$RED $CHAR $RESET"
PS2='> '
PS4='+ '
}
# Finally call the function and our prompt is all pretty
prompt
# For more prompt coolness, check out Halloween Bash:
# http://xta.github.io/HalloweenBash/
# If you break your prompt, just delete the last thing you did.
# And that's why it's good to keep your dotfiles in git too.
# Environment Variables
# =====================
# Library Paths
# These variables tell your shell where they can find certain
# required libraries so other programs can reliably call the variable name
# instead of a hardcoded path.
# NODE_PATH
# Node Path from Homebrew I believe
export NODE_PATH="/usr/local/lib/node_modules:$NODE_PATH"
# Those NODE & Python Paths won't break anything even if you
# don't have NODE or Python installed. Eventually you will and
# then you don't have to update your bash_profile
# Configurations
# GIT_MERGE_AUTO_EDIT
# This variable configures git to not require a message when you merge.
export GIT_MERGE_AUTOEDIT='no'
# Editors
# Tells your shell that when a program requires various editors, use sublime.
# The -w flag tells your shell to wait until sublime exits
export VISUAL="subl -w"
export SVN_EDITOR="subl -w"
export GIT_EDITOR="subl -w"
export EDITOR="subl -w"
# Version
# What version of the Flatiron School bash profile this is
export FLATIRON_VERSION='1.1.1'
# Paths
# The USR_PATHS variable will just store all relevant /usr paths for easier usage
# Each path is seperate via a : and we always use absolute paths.
# A bit about the /usr directory
# The /usr directory is a convention from linux that creates a common place to put
# files and executables that the entire system needs access too. It tries to be user
# independent, so whichever user is logged in should have permissions to the /usr directory.
# We call that /usr/local. Within /usr/local, there is a bin directory for actually
# storing the binaries (programs) that our system would want.
# Also, Homebrew adopts this convetion so things installed via Homebrew
# get symlinked into /usr/local
export USR_PATHS="/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin"
# Hint: You can interpolate a variable into a string by using the $VARIABLE notation as below.
# We build our final PATH by combining the variables defined above
# along with any previous values in the PATH variable.
# Our PATH variable is special and very important. Whenever we type a command into our shell,
# it will try to find that command within a directory that is defined in our PATH.
# Read http://blog.seldomatt.com/blog/2012/10/08/bash-and-the-one-true-path/ for more on that.
export PATH="$USR_PATHS:$PATH"
# If you go into your shell and type: echo $PATH you will see the output of your current path.
# For example, mine is:
# /Users/avi/.rvm/gems/ruby-1.9.3-p392/bin:/Users/avi/.rvm/gems/ruby-1.9.3-p392@global/bin:/Users/avi/.rvm/rubies/ruby-1.9.3-p392/bin:/Users/avi/.rvm/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/mysql/bin:/usr/local/share/python:/bin:/usr/sbin:/sbin:
# Helpful Functions
# =====================
# A function to CD into the desktop from anywhere
# so you just type desktop.
# HINT: It uses the built in USER variable to know your OS X username
# USE: desktop
# desktop subfolder
function desktop {
cd /Users/$USER/Desktop/$@
}
# A function to easily grep for a matching process
# USE: psg postgres
function psg {
FIRST=`echo $1 | sed -e 's/^\(.\).*/\1/'`
REST=`echo $1 | sed -e 's/^.\(.*\)/\1/'`
ps aux | grep "[$FIRST]$REST"
}
# A function to extract correctly any archive based on extension
# USE: extract imazip.zip
# extract imatar.tar
function extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Aliases
# =====================
# LS
alias l='ls -lah'
# Git
alias gcl="git clone"
alias gst="git status"
alias gl="git pull"
alias gp="git push"
alias gd="git diff | subl"
alias gc="git commit -v"
alias gca="git commit -v -a"
alias gb="git branch"
alias gba="git branch -a"
alias gcam="git commit -am"
alias gbb="git branch -b"
# Hidden File Visibility
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
# Case-Insensitive Auto Completion
bind "set completion-ignore-case on"
# Postgres
export PATH=/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH
# Final Configurations and Plugins
# =====================
# Git Bash Completion
# Will activate bash git completion if installed
# via homebrew
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
# RVM
# Mandatory loading of RVM into the shell
# This must be the last line of your bash_profile always
[[ -s "/Users/$USER/.rvm/scripts/rvm" ]] && source "/Users/$USER/.rvm/scripts/rvm" # This loads RVM into a shell session.