Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 209 lines (170 sloc) 5.67 kB
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
1 ## This file is sourced by all *interactive* bash shells on startup. This
2 ## file *should generate no output* or it will break the scp and rcp commands.
3 ############################################################
4
5 if [ -e /etc/bashrc ] ; then
6 . /etc/bashrc
7 fi
8
9 ############################################################
10 ## PATH
11 ############################################################
12
c870537 @rmm5t [bash] Simplified path management
authored
13 function conditionally_prefix_path {
14 local dir=$1
15 if [ -d $dir ]; then
16 PATH="$dir:${PATH}"
17 fi
18 }
19
20 conditionally_prefix_path /usr/local/bin
21 conditionally_prefix_path /usr/local/sbin
22 conditionally_prefix_path /usr/local/share/npm/bin
23 conditionally_prefix_path /usr/local/mysql/bin
ae641ac @rmm5t Switched from heroku gem to heroku-toolbelt
authored
24 conditionally_prefix_path /usr/local/heroku/bin
c870537 @rmm5t [bash] Simplified path management
authored
25 conditionally_prefix_path /usr/texbin
26 conditionally_prefix_path ~/bin
27 conditionally_prefix_path ~/bin/private
99dd23c @rmm5t Added MacTex to bash path if it exists
authored
28
0494259 @rmm5t Added a local ./bin dir to the front of the PATH
authored
29 PATH=.:./bin:${PATH}
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
30
31 ############################################################
63aacad @rmm5t manpath organization
authored
32 ## MANPATH
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
33 ############################################################
34
c870537 @rmm5t [bash] Simplified path management
authored
35 function conditionally_prefix_manpath {
36 local dir=$1
37 if [ -d $dir ]; then
38 MANPATH="$dir:${MANPATH}"
39 fi
40 }
63aacad @rmm5t manpath organization
authored
41
c870537 @rmm5t [bash] Simplified path management
authored
42 conditionally_prefix_manpath /usr/local/man
43 conditionally_prefix_manpath ~/man
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
44
63aacad @rmm5t manpath organization
authored
45 ############################################################
46 ## Other paths
47 ############################################################
48
c870537 @rmm5t [bash] Simplified path management
authored
49 function conditionally_prefix_cdpath {
50 local dir=$1
51 if [ -d $dir ]; then
52 CDPATH="$dir:${CDPATH}"
53 fi
54 }
55
56 conditionally_prefix_cdpath ~/work
586f392 @rmm5t Added another entry to my CDPATH
authored
57 conditionally_prefix_cdpath ~/work/oss
c870537 @rmm5t [bash] Simplified path management
authored
58
59 CDPATH=.:${CDPATH}
6ed5f77 @rmm5t Added CDPATH env var
authored
60
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
61 # Set INFOPATH so it includes users' private info if it exists
62 # if [ -d ~/info ]; then
63 # INFOPATH="~/info:${INFOPATH}"
64 # fi
65
66 ############################################################
e802179 @rmm5t Added github.token from keychain
authored
67 ## General development configurations
68 ###########################################################
69
5e3de34 @rmm5t Switched to latest rbenv and ruby-build
authored
70 if [ `which rbenv 2> /dev/null` ]; then
71 eval "$(rbenv init -)"
72 fi
73
5cf5b1c @rmm5t Added Node Version Manager
authored
74 if [ -f ~/.nvm/nvm.sh ]; then
75 . ~/.nvm/nvm.sh
76 fi
77
d6356ed @rmm5t Defaulted rubinius to 1.9 mode
authored
78 export RBXOPT=-X19
79
e802179 @rmm5t Added github.token from keychain
authored
80 ############################################################
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
81 ## Terminal behavior
82 ############################################################
83
84 # Change the window title of X terminals
85 case $TERM in
86 xterm*|rxvt|Eterm|eterm)
87 PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
88 ;;
89 screen)
90 PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
91 ;;
92 esac
93
5ab5221 @rmm5t Show the git branch and dirty state in the prompt.
authored
94 # Show the git branch and dirty state in the prompt.
95 # Borrowed from: http://henrik.nyh.se/2008/12/git-dirty-prompt
96 function parse_git_dirty {
773aefc @rmm5t Fixed prompt for when git repo is dirty
authored
97 [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
5ab5221 @rmm5t Show the git branch and dirty state in the prompt.
authored
98 }
99 function parse_git_branch {
07f44a6 @rmm5t Added rbenv gemset to the prompt if active
authored
100 git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
5ab5221 @rmm5t Show the git branch and dirty state in the prompt.
authored
101 }
102
2c388c4 @rmm5t [bash] Silence error output if programs are missing
authored
103 if [ `which git 2> /dev/null` ]; then
4e0f3f3 @rmm5t [bash] Added rvm-prompt to PS1
authored
104 function git_prompt {
105 parse_git_branch
106 }
107 else
108 function git_prompt {
109 echo ""
110 }
111 fi
112
a2ef449 @rmm5t Switched to using rbenv over rvm
authored
113 if [ `which rbenv 2> /dev/null` ]; then
114 function ruby_prompt {
07f44a6 @rmm5t Added rbenv gemset to the prompt if active
authored
115 echo $(rbenv version-name)
4e0f3f3 @rmm5t [bash] Added rvm-prompt to PS1
authored
116 }
b41cb7b @rmm5t Added fallback to ruby prompt in case rbenv isn't installed
authored
117 elif [ `which ruby 2> /dev/null` ]; then
118 function ruby_prompt {
07f44a6 @rmm5t Added rbenv gemset to the prompt if active
authored
119 echo $(ruby --version | cut -d' ' -f2)
b41cb7b @rmm5t Added fallback to ruby prompt in case rbenv isn't installed
authored
120 }
4e0f3f3 @rmm5t [bash] Added rvm-prompt to PS1
authored
121 else
a2ef449 @rmm5t Switched to using rbenv over rvm
authored
122 function ruby_prompt {
4e0f3f3 @rmm5t [bash] Added rvm-prompt to PS1
authored
123 echo ""
124 }
125 fi
126
07f44a6 @rmm5t Added rbenv gemset to the prompt if active
authored
127 if [ `which rbenv-gemset 2> /dev/null` ]; then
128 function gemset_prompt {
129 local gemset=$(rbenv gemset active 2> /dev/null)
130 if [ $gemset ]; then
848949f @rmm5t Fixed gemset prompt typo
authored
131 echo " ${gemset}"
07f44a6 @rmm5t Added rbenv gemset to the prompt if active
authored
132 fi
133 }
134 else
135 function gemset_prompt {
136 echo ""
137 }
138 fi
139
3e2644d @rmm5t [emacs] Set the tab-width for shell-mode to 8
authored
140 if [ -n "$BASH" ]; then
07f44a6 @rmm5t Added rbenv gemset to the prompt if active
authored
141 export PS1='\[\033[32m\]\n[\s: \w] ($(ruby_prompt)$(gemset_prompt)) $(git_prompt)\n\[\033[31m\][\u@\h]\$ \[\033[00m\]'
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
142 fi
143
144 ############################################################
145 ## Optional shell behavior
146 ############################################################
147
148 shopt -s cdspell
149 shopt -s extglob
150 shopt -s checkwinsize
151
152 export PAGER="less"
4e71f63 @rmm5t Removed terminal-only mode for EDITOR env variable
authored
153 export EDITOR="emacsclient"
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
154
155 ############################################################
3bcfe78 @rmm5t Wicked history behavior (Thanks Chris Murphy)
authored
156 ## History
157 ############################################################
158
159 # When you exit a shell, the history from that session is appended to
160 # ~/.bash_history. Without this, you might very well lose the history of entire
161 # sessions (weird that this is not enabled by default).
162 shopt -s histappend
163
164 export HISTIGNORE="&:pwd:ls:ll:lal:[bf]g:exit:rm*:sudo rm*"
165 # remove duplicates from the history (when a new item is added)
166 export HISTCONTROL=erasedups
167 # increase the default size from only 1,000 items
168 export HISTSIZE=10000
169
170 ############################################################
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
171 ## Aliases
172 ############################################################
173
4e0f3f3 @rmm5t [bash] Added rvm-prompt to PS1
authored
174 if [ -e ~/.bash_aliases ]; then
8b2a087 @rmm5t Adding bash_aliases after seeing Mislav's convention. Cleanup and re…
authored
175 . ~/.bash_aliases
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
176 fi
177
178 ############################################################
179 ## Bash Completion, if available
180 ############################################################
181
e67f606 @rmm5t Hard coded brew prefix location (for reuse in other environments lack…
authored
182 if [ -f /usr/local/etc/bash_completion ]; then
183 . /usr/local/etc/bash_completion
9bb9d26 @rmm5t Added support for brew managed bash-completion
authored
184 elif [ -f /etc/bash_completion ]; then
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
185 . /etc/bash_completion
186 elif [ -f /etc/profile.d/bash_completion ]; then
187 . /etc/profile.d/bash_completion
12f7a04 @rmm5t Moved custom bash completions into its own file
authored
188 elif [ -e ~/.bash_completion ]; then
189 # Fallback. This should be sourced by the above scripts.
190 . ~/.bash_completion
0033e4a @rmm5t git bash completion added
authored
191 fi
192
f1c8af8 Mad props to Chris Wanstrath for this convention
Ryan McGeary authored
193 ############################################################
194 ## Other
195 ############################################################
196
197 if [[ "$USER" == '' ]]; then
198 # mainly for cygwin terminals. set USER env var if not already set
199 USER=$USERNAME
200 fi
27f48c0 @rmm5t Added ruby optimization env vars
authored
201
202 ############################################################
203 ## Ruby Performance Boost (see https://gist.github.com/1688857)
204 ############################################################
205
206 export RUBY_GC_MALLOC_LIMIT=60000000
f41d921 @rmm5t Fixed typo in bashrc comment
authored
207 # export RUBY_FREE_MIN=200000 # Ruby <= 2.0
ff0dcf6 @rmm5t Switched env vars to benefit ruby 2.1.0
authored
208 export RUBY_GC_HEAP_FREE_SLOTS=200000 # Ruby >= 2.1
Something went wrong with that request. Please try again.