-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc
205 lines (171 loc) · 5.18 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
# shellcheck shell=bash
# -*- mode: sh; -*-
# vi: set ft=sh :
: "${HOME=~}"
: "${LOGNAME=$(id -un)}"
: "${UNAME=$(uname)}"
: "${HOSTFILE=~/.ssh/known_hosts}"
: "${INPUTRC=~/.inputrc}"
: "${LANG:="en_GB.UTF-8"}"
: "${LANGUAGE:="en"}"
: "${LC_CTYPE:="en_GB.UTF-8"}"
: "${LC_ALL:="en_GB.UTF-8"}"
export LANG LANGUAGE LC_CTYPE LC_ALL
ulimit -S -c 0
shopt -s cdspell >/dev/null 2>&1
shopt -s extglob >/dev/null 2>&1
shopt -s histappend >/dev/null 2>&1
shopt -s hostcomplete >/dev/null 2>&1
shopt -s interactive_comments >/dev/null 2>&1
shopt -s no_empty_cmd_completion >/dev/null 2>&1
shopt -u mailwarn >/dev/null 2>&1
set -o emacs
set -o notify
unset MAILCHECK
unset TERMCAP
shopt -s histappend
HISTSIZE=
HISTFILESIZE=
HISTCONTROL=ignoredups:erasedups
HISTIGNORE="&:l:ls:ll:cd:exit:clear:pwd:history:h:#*"
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
IS_LINUX=false
[[ "$(uname -s)" =~ Linux|GNU|GNU/* ]] && IS_LINUX=true
export IS_LINUX
IS_OSX=false
[[ "$(uname -s)" =~ Darwin ]] && IS_OSX=true
export IS_OSX
[[ "${IS_OSX}" == true ]] && {
[[ -f ~/.osx ]] && . ~/.osx
architecture="$(uname -m)"
if [ "${architecture}" = "x86_64" ]; then
export BREW_PREFIX='/usr/local'
eval "$(/usr/local/bin/brew shellenv)"
else
export BREW_PREFIX='/opt/homebrew'
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
if ! grep -F -q "${BREW_PREFIX}/bin/bash" /etc/shells; then
echo "${BREW_PREFIX}/bin/bash" | sudo tee -a /etc/shells;
chsh -s "${BREW_PREFIX}/bin/bash";
fi;
_ls_colors='fi=00;00:' # file
_ls_colors+='pi=04;91:' # fifo
_ls_colors+='so=00;95:' # socket
_ls_colors+='ln=00;32:' # symlink
_ls_colors+='di=00;94:' # directory
_ls_colors+='ex=00;31:' # executable
_ls_colors+='bd=04;93:' # block special
_ls_colors+='cd=00;93:' # character special
_ls_colors+='or=07;31:' # symlink to non-existent
_ls_colors+='*.gz=01;31:'
_ls_colors+='*.tar=01;31:'
_ls_colors+='*.tgz=01;31:'
_ls_colors+='*.tbz=01;31:'
_ls_colors+='*.zip=01;31:'
_ls_colors+='*.org=01;93:'
LS_COLORS="${_ls_colors}"
CC="$(command -v clang)"
export LS_COLORS CC
# shellcheck disable=SC1091
[[ -f "${BREW_PREFIX}/etc/profile.d/bash_completion.sh" ]] &&
. "${BREW_PREFIX}/etc/profile.d/bash_completion.sh"
[[ -d "${BREW_PREFIX}/etc/bash_completion.d/" ]] &&
for f in "${BREW_PREFIX}"/etc/bash_completion.d/*; do . "${f}"; done
[[ -f ~/.iterm2_shell_integration.bash ]] &&
. ~/.iterm2_shell_integration.bash
PATH="${BREW_PREFIX}/opt/gawk/libexec/gnubin:$PATH"
PATH="${BREW_PREFIX}/opt/gsed/libexec/gnubin:$PATH"
if [[ $ITERM_SESSION_ID ]]; then
export DISABLE_AUTO_TITLE="true"
# Sets the tab title to current dir.
export PROMPT_COMMAND='echo -ne "\033]0;${PWD##*/}$(__git_ps1 :%s)\007"'
fi
}
_set_preferred() {
local IFS=":" var="$1" list="$2" item
for item in $list; do
program="$(command -v "${item}" 2>/dev/null)"
if [[ -x "${program}" ]]; then
printf -v "${var}" %s "${program}"
break
fi
done
}
editors="vim:vi:emacs"
browsers="elinks:lynx:links"
xbrowsers="chromium:firefox:uzbl"
greppage="rg:ack:grep"
_set_preferred "VISUAL" $editors
_set_preferred "EDITOR" $editors
_set_preferred "GREPPAGE" $greppage
[[ "${IS_LINUX}" == true ]] && {
if [[ "${DISPLAY}" == true ]]; then
_set_preferred "BROWSER" $xbrowsers
else
_set_preferred "BROWSER" $browsers
fi
export BROWSER
}
export VISUAL EDITOR GREPPAGE
if command -v less >/dev/null 2>&1; then
LESS="-FiRswX"
PAGER="less"
MANPAGER="${PAGER}"
export LESS PAGER MANPAGER
else
PAGER="more"
MANPAGER="${PAGER}"
export PAGER MANPAGER
fi
SHELLCHECK_OPTS="-e SC1090,SC1092,SC2148"
export SHELLCHECK_OPTS
WORKON_HOME="${HOME}/.virtualenvs"
PIP_REQUIRE_VIRTUALENV=true
VIRTUAL_ENV_DISABLE_PROMPT=1
export WORKON_HOME PIP_REQUIRE_VIRTUALENV VIRTUAL_ENV_DISABLE_PROMPT
[[ -f ~/.bash-aliases ]] &&
. ~/.bash-aliases
[[ -f ~/.git-aliases ]] &&
. ~/.git-aliases
[[ -f ~/.nix-aliases ]] &&
. ~/.nix-aliases
[[ -f ~/.private ]] &&
. ~/.private
[[ -f ~/.fzf.bash ]] &&
. ~/.fzf.bash
export NVM_DIR="$HOME/.nvm"
[ -s "${BREW_PREFIX}/opt/nvm/nvm.sh" ] && \
. "${BREW_PREFIX}/opt/nvm/nvm.sh"
[ -s "${BREW_PREFIX}/opt/nvm/etc/bash_completion.d/nvm" ] && \
. "${BREW_PREFIX}/opt/nvm/etc/bash_completion.d/nvm"
mpd-start() {
if command -v 'mpd' >/dev/null 2>&1; then
if ! pgrep -xU "${UID}" 'mpd' >/dev/null 2>&1; then
[[ -f "${HOME}/.mpd/mpd.conf" ]] && {
mpd "${HOME}/.mpd/mpd.conf" -v
# Make sure the scrobbler is running if we are starting mpd.
if command -v 'mpdscribble' >/dev/null 2>&1; then
if ! pgrep -xU "${UID}" 'mpdscribble' >/dev/null 2>&1; then
[[ -f "${HOME}/.mpdscribble/mpdscribble.conf" ]] &&
mpdscribble --conf "${HOME}/.mpdscribble/mpdscribble.conf" &
fi
fi
}
fi
fi
}
mpd-start
mpd-restart() {
mpd --kill && mpd-start
}
if command -v 'gpg-agent' >/dev/null 2>&1; then
if ! pgrep -xU "${UID}" 'gpg-agent' >/dev/null 2>&1; then
eval "$(gpg-agent --daemon)"
fi
fi
[[ "${IS_LINUX}" == true ]] && {
if command -v 'keychain' >/dev/null 2>&1; then
eval "$(keychain --eval --agents ssh -Q --quiet jhrr_id_rsa cmg_id_rsa)"
fi
}