forked from dustinchang/dot_files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_profile
243 lines (190 loc) · 7.08 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#Git Completion
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
#Terminal Colors
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
#0D2D37 for background color
#To get Git branch name in the Terminal
##export GITAWAREPROMPT=~/.bash/git-aware-prompt
##source "${GITAWAREPROMPT}/main.sh"
##export PS1="\u@\h \w \[$txtcyn\]\$git_branch\[$txtwht\]\$git_dirty\[$txtrst\]\$ "
#sml
export PATH="$PATH:/usr/local/Cellar/smlnj-110.77/bin"
#NodeJS (Mac) - need access to dir for commands
export PATH=$PATH:/usr/local/bin
#alias
alias ..="cd .."
alias ....="cd ../.."
alias ......="cd ../../.."
alias spro='sublime ~/.bash_profile'
alias vpro='vim ~/.bash_profile'
alias szrc='sublime ~/.zshrc'
alias vzrc='vim ~/.zshrc'
alias vrc='vim ~/.vimrc'
alias s='git status'
alias b='git branch'
alias a='git add'
alias c='git commit -m'
alias pull='git pull'
alias pyserv='python -m SimpleHTTPServer'
alias sublime="open -a /Applications/Sublime\ Text\ 2.app"
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO'
alias mongod="sudo /Applications/mongodb-osx-x86_64-3.0.4/bin/mongod"
alias mongo="sudo /Applications/mongodb-osx-x86_64-3.0.4/bin/mongo"
#Inspiration dot files
# https://github.com/alrra/dotfiles/blob/master/shell/bash_prompt
# https://github.com/mathiasbynens/dotfiles
enable_color_support() {
if [[ $COLORTERM == gnome-* && $TERM == xterm ]] \
&& infocmp gnome-256color &> /dev/null; then
export TERM='gnome-256color'
elif infocmp xterm-256color &> /dev/null; then
export TERM='xterm-256color'
fi
if [ "$OS" == "osx" ]; then
alias ls='ls -G' # or CLICOLOR=1
elif [ "$OS" == "ubuntu" ]; then
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors \
&& eval "$(dircolors -b ~/.dircolors)" \
|| eval "$(dircolors -b)"
alias dir='dir --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias ls='ls --color=auto'
alias vdir='vdir --color=auto'
fi
fi
}
get_git_repository_details() {
local branchName=''
local tmp=''
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Check if the current directory is in a Git repository
[ "$(git rev-parse &>/dev/null; printf $?)" -ne 0 ] && return
# Check if in `.git/` directory (some of the following
# checks don't make sense/won't work in the `.git` directory)
[ "$(git rev-parse --is-inside-git-dir)" == "true" ] && return
# Check for uncommitted changes in the index
if ! $(git diff --quiet --ignore-submodules --cached); then
tmp="$tmp+";
fi
# Check for unstaged changes
if ! $(git diff-files --quiet --ignore-submodules --); then
tmp="$tmp!";
fi
# Check for untracked files
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
tmp="$tmp?";
fi
# Check for stashed files
if $(git rev-parse --verify refs/stash &>/dev/null); then
tmp="$tmp$";
fi
[ -n "$tmp" ] && tmp=" [$tmp]"
branchName="$( printf "$( git rev-parse --abbrev-ref HEAD 2> /dev/null \
|| git rev-parse --short HEAD 2> /dev/null \
|| printf " (unknown)" )" | tr -d "\n" )"
printf "%s" "$1$branchName$tmp"
}
set_prompts() {
local black='' blue='' bold='' cyan='' green='' orange='' \
purple='' red='' reset='' white='' yellow=''
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ -x /usr/bin/tput ] && tput setaf 1 &> /dev/null; then
tput sgr0 # Reset colors
bold=$(tput bold)
reset=$(tput sgr0)
# Solarized colors
# https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized#the-values
black=$(tput setaf 0)
blue=$(tput setaf 33)
cyan=$(tput setaf 37)
green=$(tput setaf 64)
orange=$(tput setaf 166)
purple=$(tput setaf 61) #125)
red=$(tput setaf 124)
white=$(tput setaf 15)
yellow=$(tput setaf 136)
violet=$(tput setaf 125) #61)
else
bold=''
reset="\e[0m"
black="\e[1;30m"
blue="\e[1;34m"
cyan="\e[1;36m"
green="\e[1;32m"
orange="\e[1;33m"
purple="\e[1;35m"
red="\e[1;31m"
white="\e[1;37m"
yellow="\e[1;33m"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Prompt Statement variables
# http://ss64.com/bash/syntax-prompt.html
# ------------------------------------------------------------------
# | PS1 - Default interactive prompt |
# ------------------------------------------------------------------
PS1="\[\033]0;\w\007\]" # Terminal title (set to the
# current working directory)
PS1+="\[$bold\]"
PS1+="\[$orange\]\u" # Username
PS1+="\[$white\]@"
# DON'T SHOW THE HOST PS1+="\[$yellow\]\h" # Host
PS1+="\[$white\]: "
PS1+="\[$green\]\w" # Working directory
PS1+="\$(get_git_repository_details \"$white on $cyan\")"
PS1+="\n"
PS1+="\[$reset$white\]\$ \[$reset\]"
export PS1
# ------------------------------------------------------------------
# | PS2 - Continuation interactive prompt |
# ------------------------------------------------------------------
PS2='⚡ '
export PS2
# ------------------------------------------------------------------
# | PS4 - Debug prompt |
# ------------------------------------------------------------------
# e.g:
#
# The GNU `date` command has the `%N` interpreted sequence while
# other implementations don't (on OS X `gdate` can be used instead
# of the native `date` if the `coreutils` package was installed)
#
# local dateCmd=""
#
# if [ "$(date +%N)" != "N" ] || \
# [ ! -x "$(command -v 'gdate')" ]; then
# dateCmd="date +%s.%N"
# else
# dateCmd="gdate +%s.%N"
# fi
#
# PS4="+$( tput cr && tput cuf 6 &&
# printf "$yellow %s $green%6s $reset" "$($dateCmd)" "[$LINENO]" )"
#
# PS4 output:
#
# ++ 1357074705.875970000 [123] '[' 1 == 0 ']'
# └──┬─┘└────┬───┘ └───┬───┘ └──┬─┘ └──────┬─────┘
# │ │ │ │ │
# │ │ │ │ └─ command
# │ │ │ └─ line number
# │ │ └─ nanoseconds
# │ └─ seconds since 1970-01-01 00:00:00 UTC
# └─ depth-level of the subshell
PS4="+$( tput cr && tput cuf 6 && printf "%s $reset" )"
export PS4
}
main() {
enable_color_support
set_prompts
}
main
unset -f enable_color_support
unset -f set_prompts