forked from rmm5t/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc
270 lines (216 loc) · 7.36 KB
/
bashrc
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
## This file is sourced by all *interactive* bash shells on startup. This
## file *should generate no output* or it will break the scp and rcp commands.
############################################################
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
if [ -e /etc/bashrc ] ; then
. /etc/bashrc
fi
############################################################
## PATH
############################################################
function conditionally_prefix_path {
local dir=$1
if [ -d $dir ]; then
case ":$PATH:" in
*":$dir:"*) :;;
*) PATH="$dir:$PATH";;
esac
fi
}
conditionally_prefix_path $HOME/android/platform-tools
conditionally_prefix_path /usr/lib/ccache
conditionally_prefix_path /opt/gcc-arm-none-eabi-4_9-2015q3/bin
conditionally_prefix_path $HOME/anaconda2/bin
conditionally_prefix_path $HOME/go/bin
conditionally_prefix_path $HOME/.cargo/bin
PATH=.:./bin:${PATH}
############################################################
## MANPATH
############################################################
function conditionally_prefix_manpath {
local dir=$1
if [ -d $dir ]; then
MANPATH="$dir:${MANPATH}"
fi
}
conditionally_prefix_manpath /usr/local/man
conditionally_prefix_manpath ~/man
############################################################
## Other paths
############################################################
function conditionally_prefix_cdpath {
local dir=$1
if [ -d $dir ]; then
CDPATH="$dir:${CDPATH}"
fi
}
conditionally_prefix_cdpath ~/work
conditionally_prefix_cdpath ~/work/oss
CDPATH=.:${CDPATH}
# Set INFOPATH so it includes users' private info if it exists
# if [ -d ~/info ]; then
# INFOPATH="~/info:${INFOPATH}"
# fi
############################################################
## General development configurations
###########################################################
if [ `which rbenv 2> /dev/null` ]; then
eval "$(rbenv init -)"
fi
if [ -f ~/.nvm/nvm.sh ]; then
. ~/.nvm/nvm.sh
fi
export RBXOPT=-X19
############################################################
## Terminal behavior
############################################################
# Change the window title of X terminals
case $TERM in
xterm*|rxvt|Eterm|eterm)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac
# Show the git branch and dirty state in the prompt.
# Borrowed from: http://henrik.nyh.se/2008/12/git-dirty-prompt
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
if [ `which git 2> /dev/null` ]; then
function git_prompt {
parse_git_branch
}
else
function git_prompt {
echo ""
}
fi
if [ `which rbenv 2> /dev/null` ]; then
function ruby_prompt {
echo $(rbenv version-name)
}
elif [ `which ruby 2> /dev/null` ]; then
function ruby_prompt {
echo $(ruby --version | cut -d' ' -f2)
}
else
function ruby_prompt {
echo ""
}
fi
if [ `which rbenv-gemset 2> /dev/null` ]; then
function gemset_prompt {
local gemset=$(rbenv gemset active 2> /dev/null)
if [ $gemset ]; then
echo " ${gemset}"
fi
}
else
function gemset_prompt {
echo ""
}
fi
normal_color=$'\033[00m'
red_color=$'\033[41m'
exit_color=$normal_color
exit_color() {
exit_code=$?
if [ "$exit_code" != 0 ]; then
echo "$red_color"
else
echo "$normal_color"
fi
return "$exit_code"
}
if [ -n "$BASH" ]; then
export PS1='\[$normal_color\]\n\[$(exit_color)\][$?]\[$normal_color\]\[\033[32m\][\s: \w] $(git_prompt)\n\[\033[31m\][\u@\h]\$ \[\033[00m\]'
fi
# Fuzzy completion
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
############################################################
## Optional shell behavior
############################################################
shopt -s cdspell
shopt -s extglob
shopt -s checkwinsize
export PAGER="less"
export EDITOR="emacsclient -t"
############################################################
## History
############################################################
# When you exit a shell, the history from that session is appended to
# ~/.bash_history. Without this, you might very well lose the history of entire
# sessions (weird that this is not enabled by default).
shopt -s histappend
export HISTIGNORE="&:pwd:ls:ll:lal:[bf]g:exit:rm*:sudo rm*"
# don't remove duplicates from the history (when a new item is added)
export HISTCONTROL=
# increase the default size from only 1,000 items
export HISTSIZE=-1
export HISTFILESIZE=-1
############################################################
## Aliases
############################################################
if [ -e ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
############################################################
## Bash Completion, if available
############################################################
if [ -f /usr/local/etc/bash_completion ]; then
. /usr/local/etc/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
elif [ -f /etc/profile.d/bash_completion ]; then
. /etc/profile.d/bash_completion
elif [ -e ~/.bash_completion ]; then
# Fallback. This should be sourced by the above scripts.
. ~/.bash_completion
fi
complete -C /home/nigelarmstrong/bin/vault vault
############################################################
## Other
############################################################
if [[ "$USER" == '' ]]; then
# mainly for cygwin terminals. set USER env var if not already set
USER=$USERNAME
fi
############################################################
## Ruby Performance Boost (see https://gist.github.com/1688857)
############################################################
export RUBY_GC_MALLOC_LIMIT=60000000
# export RUBY_FREE_MIN=200000 # Ruby <= 2.0
export RUBY_GC_HEAP_FREE_SLOTS=200000 # Ruby >= 2.1
############################################################
## Django bash completions
############################################################
if [ -f $HOME/.django_bash_completion ]; then
source $HOME/.django_bash_completion
fi
############################################################
## Java and Android
############################################################
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/"
export ANDROID_HOME="$HOME/Android/Sdk"
############################################################
## WSL support
############################################################
if grep -iq Microsoft /proc/version; then
export LIBGL_ALWAYS_INDIRECT=1
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0 # in WSL 2
fi
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# tabtab source for yarn package
# uninstall by removing these lines or running `tabtab uninstall yarn`
[ -f /home/nigel/.nvm/versions/node/v16.17.1/lib/node_modules/yarn-completions/node_modules/tabtab/.completions/yarn.bash ] && . /home/nigel/.nvm/versions/node/v16.17.1/lib/node_modules/yarn-completions/node_modules/tabtab/.completions/yarn.bash
# Generated for envman. Do not edit.
[ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh"