-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_profile
247 lines (205 loc) · 7.44 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
244
245
246
247
ORIGINAL_PATH=$PATH
PATH=""
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
if [ -n "$BASH_VERSION" ]; then
if [ -f $(brew --prefix)/share/bash-completion/bash_completion ]; then
source $(brew --prefix)/share/bash-completion/bash_completion
fi
if [ -f $(brew --prefix)/etc/autojump.sh; then
source $(brew --prefix)/etc/autojump.sh
fi
# if [ -f ~/.git-completion.sh ]; then
# source ~/.git-completion.sh
# fi
fi
# source chruby scripts if running either bash or zsh shell
if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
source /usr/local/opt/chruby/share/chruby/chruby.sh
source /usr/local/opt/chruby/share/chruby/auto.sh
chruby 2.2.2
fi
#### Smooth the way for DTerm and possibly other terminals that barf on tput colors:
# TODO: Find source; might not need
INTERACTIVETERM=-YES-
if [ "$TERM" == "" ]; then INTERACTIVETERM="-NO-"; TERM="vt100"; fi
if [ "$TERM" == "dumb" ]; then INTERACTIVETERM="-NO-"; TERM="vt100"; fi
export INTERACTIVETERM
# Set up TPUT color codes
if [ "$INTERACTIVETERM" == "-YES-" ]; then
tReset="$(tput sgr0)"
NORMAL=$(tput sgr0)
tBold="$(tput bold)"
BOLD=$(tput bold)
BRIGHT=$(tput bold)
tBlack="$(tput setaf 0)"
BLACK=$(tput setaf 0)
tRed="$(tput setaf 1)"
RED=$(tput setaf 1)
tGreen="$(tput setaf 2)"
GREEN=$(tput setaf 2)
tYellow="$(tput setaf 3)"
YELLOW=$(tput setaf 3)
pYELLOW="$(tput setaf 190)"
LIME_YELLOW=$(tput setaf 190)
tBlue="$(tput setaf 4)"
BLUE=$(tput setaf 4)
POWDER_BLUE=$(tput setaf 153)
tPink="$(tput setaf 5)"
MAGENTA=$(tput setaf 5)
tCyan="$(tput setaf 6)"
CYAN=$(tput setaf 6)
tGray="$(tput setaf 7)"
WHITE=$(tput setaf 7)
tWhite="$(tput setaf 8)"
TUNON="$(tput smul)"
TUNOFF="$(tput rmul)"
BLINK=$(tput blink)
REVERSE=$(tput smso)
UNDERLINE=$(tput smul)
# tRandColor=$(tput setaf $(random /0..8/))
# tRandColor="$(tput setaf $(( $(hostname | openssl sha1 | sed 's/.*\([0-9]\).*/\1/') % 6 + 1 )) )"
else
tReset=
tBold=
tBlack=
tRed=
tGreen=
tYellow=
tBlue=
tPink=
tCyan=
tGray=
tWhite=
tUndOn=
tUndOff=
tRandColor=
BLACK=
RED=
GREEN=
YELLOW=
BLUE=
MAGENTA=
CYAN=
WHITE=
LIME_YELLOW=
POWDER_BLUE=
BRIGHT=
NORMAL=
BLINK=
REVERSE=
UNDERLINE=
BOLD=
fi
# Add color to terminal output
export CLICOLOR=1
export LSCOLORS=exfxcxdxbxegedabagacad
# Show dirty state when GIT status is fucked up
GIT_PS1_SHOWDIRTYSTATE=1 #... untagged(*) and staged(+) changes
GIT_PS1_SHOWSTASHSTATE=1 #... if something is stashed($)
GIT_PS1_SHOWUNTRACKEDFILES=1 #... untracked files(%)
GIT_PS1_SHOWUPSTREAM="auto" #... 'verbose' .. others avaliable
##########################################
# Commonly-Used Aliases #
##########################################
# Colorized output of: list of git branches, ordered by most recent commit
# via @estani (from: http://stackoverflow.com/a/18310499)
alias glist='for ref in $(git for-each-ref --sort=-committerdate --format="%(refname)" refs/heads/ refs/remotes ); do git log -n1 $ref --pretty=format:"%Cgreen%cr%Creset %C(yellow)%d%Creset %C(bold blue)<%an>%Creset%n" | cat ; done | awk '"'! a["'$0'"]++'"
# Commonly used aliases
alias l='ls -CF'
alias ls='ls -l'
alias ll='ls -alF'
alias lld='ls -d */'
alias trim_whitespace="sh ~/development/dotfiles/trim_whitespace"
alias clear_toolbar="killall -KILL SystemUIServer"
# Prompt for confirmation when deleting
alias rm='rm -i'
# Show command history, sorted by most-used command(s)
# Not sure where I found this one
alias history_ranking="sed '/^#/d' ~/.bash_history | awk '{print \$1}' | sort | uniq -c | sort -nr | head -20 | cat -n"
# Source ~/.bash_profile in shell
alias reloadProfile='export PATH=$ORIGINAL_PATH && source ~/.bash_profile && echo "SUCCESS: ~/.bash_profile reloaded!"'
# Flush Mac OSX DNS cache
alias flush_dns_cache='dscacheutil -flushcache'
##########################################
# JS / Node-Related Aliases #
##########################################
alias nv10='nvm use 0.10' # You do not need to specify the patch version
alias nv11='nvm use 0.11' # in order for it to load the most up-to-date ver.
alias nv12='nvm use 0.12'
##########################################
# Ruby-Related Aliases #
##########################################
alias b='bundle'
alias be='b exec'
# Run bundle using Gemfile.local
alias belocal='be --gemfile Gemfile.local'
# Gist gem: make private by default
alias gist='gist -p'
# Pry rails console
alias pryConsole='pry -r ./config/environment'
##########################################
# Default Programs #
##########################################
# TODO: Fix this mess below
# export EDITOR="/usr/local/bin/atom -w"
export EDITOR="/usr/local/bin/subl -w"
export mate="/usr/local/bin/mate"
alias slime=subl
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=10000
HISTFILESIZE=20000
HISTTIMEFORMAT='%F %T '
HISTIGNORE="&:[ ]*:exit"
# So that bash doesn't overwrite history on exit
# append to the history file, don't overwrite it
shopt -s histappend
# Save multi-line commands to the history as one command
shopt -s cmdhist
# Enable the new features of Bash 4.0
# Bash 4.0
if [ $BASH_VERSINFO -ge 4 ]; then
# Completion, ** expands recursively
shopt -s globstar
# If set, a command name that is the name of a directory is executed as if it were the argument to the cd command. This option is only used by interactive shells.
shopt -s autocd
# If set, Bash attempts spelling correction on directory names during word completion if the directory name initially supplied does not exist.
shopt -s dirspell
fi
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Make directory commands see only directories
complete -d pushd
# Resets <CTRL>-S from being scroll stop so that bash can forward search
# Required in OS X
# TODO: Find source
stty stop ""
# Some kind of magical autocomplete thing I read somewhere
# TODO: research this shit. possibly delete. yeah. good times.
complete -o default -o nospace -F _git g
# Move this to git config instead. Duh.
# Via: https://coderwall.com/p/euwpig
alias pretty-log="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# # Search function (returns the first google result)
search () {
curl -s --get --data-urlencode "q=$*" http://ajax.googleapis.com/ajax/services/search/web?v=1.0 | \
sed 's/"unescapedUrl":"\([^"]*\).*/\1/;s/.*GwebSearch",//'
}
# # function to make a directory and then cd into it
# function make_dir_and_cd () {
# mkdir -p "$@" && cd $_
# }
# Custom prompt (with git status when in repo)
export PS1='\[${tBlue}\]\W\[${tReset}${tGreen}\]$(__git_ps1 "[%s]")$\[${tReset}\]⇶ '
export PS1="$PS1"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I_#P") "$PWD")'
# Custom Prompt
PS1='${tBlue}[\W$(__git_ps1 " (%s)")]${tGreen}\$ ${tReset}'
# Custom Terminal Title (PWD)??
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'
# One-liner that copies to the clipboard the previous 24-hours' worth of git-activity (in `pwd`) - Credit: Jacob Lowe (@jcblw)
alias copy-whatididtoday="git-activity --json --me | stream-json-clipboard -k message --humanize -p'- '"