-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathbashrc
More file actions
186 lines (150 loc) · 4.72 KB
/
bashrc
File metadata and controls
186 lines (150 loc) · 4.72 KB
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
#!/bin/bash
#
# Mitchell Hashimoto's bash environment
# Much taken from Ryan Tomayko (thanks!)
# Basics
: ${HOME=~}
: ${LOGNAME=$(id -un)}
: ${UNAME=$(uname)}
# Complete hostnames from this file
: ${HOSTFILE=~/.ssh/known_hosts}
#-------------------------------------------------------------------------------
# Shell Options
#-------------------------------------------------------------------------------
# System bashrc
test -r /etc/bash.bashrc && . /etc/bash.bashrc
# Notify bg task completion immediately
set -o notify
# Fucking mail notifications
unset MAILCHECK
# default umask
umask 0022
#-------------------------------------------------------------------------------
# Path
#-------------------------------------------------------------------------------
# Various sbins
PATH="/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin"
PATH="/usr/local/bin:$PATH"
# Append macports bin (/opt) if on mac
if [[ `uname` == "Darwin" ]]; then
PATH="/opt/local/bin:/opt/local/sbin:$PATH"
elif [[ `uname` == "Linux" ]]; then
PATH="/usr/bin/perlbin/vendor:$PATH"
fi
# ~/bin if it exists
test -d "$HOME/bin" &&
PATH="$HOME/bin:$PATH"
#-------------------------------------------------------------------------------
# Env. Configuration
#-------------------------------------------------------------------------------
# detect interactive shell
case "$-" in
*i*) INTERACTIVE=yes ;;
*) unset INTERACTIVE ;;
esac
# detect login shell
case "$0" in
-*) LOGIN=yes ;;
*) unset LOGIN ;;
esac
# Proper locale
: ${LANG:="en_US.UTF-8"}
: ${LANGUAGE:="en"}
: ${LC_CTYPE:="en_US.UTF-8"}
: ${LC_ALL:="en_US.UTF-8"}
export LANG LANGUAGE LC_CTYPE LC_ALL
# Always use passive mode FTP
: ${FTP_PASSIVE:=1}
export FTP_PASSIVE
# Ignore backups, CVS directories
FIGNORE="~:CVS:#:.pyc"
HISTCONTROL=ignoreboth
#-------------------------------------------------------------------------------
# Editor and Pager
#-------------------------------------------------------------------------------
EDITOR="emacs -nw"
export EDITOR
PAGER="less -FirSwX"
MANPAGER="$PAGER"
export PAGER MANPAGER
#-------------------------------------------------------------------------------
# Prompt
#-------------------------------------------------------------------------------
RED="\[\033[0;31m\]"
BROWN="\[\033[0;33m\]"
GREY="\[\033[0;97m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
PS_CLEAR="\[\033[0m\]"
SCREEN_ESC="\[\033k\033\134\]"
COLOR1="${BLUE}"
COLOR2="${BLUE}"
P="\$"
prompt_simple() {
unset PROMPT_COMMAND
PS1="\W\$(parse_git_branch) → "
PS2="> "
}
prompt_compact() {
unset PROMPT_COMMAND
PS1="${COLOR1}${P}${PS_CLEAR} "
PS2="> "
}
prompt_color() {
PS1="${GREEN}\W\$(parse_git_branch) → ${GREY}"
PS2="\[[33;1m\]continue \[[0m[1m\]> "
}
parse_git_branch() {
[ -d .git ] || return 1
git symbolic-ref HEAD 2> /dev/null | sed 's#\(.*\)\/\([^\/]*\)$# \2#'
}
#-------------------------------------------------------------------------------
# Aliases / Functions
#-------------------------------------------------------------------------------
alias dul='du -h --max-depth=1'
alias hi='history | tail -20'
# Git aliases
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git prettylog'
alias gcp='git cherry-pick'
alias gco='git checkout'
# Others
alias v='vagrant'
# Usage: puniq [path]
# Remove duplicate entries from a PATH style value while
# retaining the original order.
puniq() {
echo "$1" |tr : '\n' |nl |sort -u -k 2,2 |sort -n |
cut -f 2- |tr '\n' : |sed -e 's/:$//' -e 's/^://'
}
#-------------------------------------------------------------------------------
# RVM
#-------------------------------------------------------------------------------
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi
#-------------------------------------------------------------------------------
# Java Stuff
#-------------------------------------------------------------------------------
test -f "$HOME/.java/bashrc" && source "$HOME/.java/bashrc"
#-------------------------------------------------------------------------------
# AWS Stuff
#-------------------------------------------------------------------------------
test -f "$HOME/.aws/bashrc" && source "$HOME/.aws/bashrc"
#-------------------------------------------------------------------------------
# User Shell Environment
#-------------------------------------------------------------------------------
# Set java home
if [[ `uname` == "Darwin" ]]; then
JAVA_HOME=`/usr/libexec/java_home`
elif [[ `uname` == "Linux" ]]; then
JAVA_HOME="/usr/lib/jvm/java-6-sun/"
fi
export JAVA_HOME
# Condense path variables
PATH=$(puniq $PATH)
MANPATH=$(puniq $MANPATH)
# Set default prompt if interactive
test -n "$PS1" &&
prompt_color