-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_bashrc
319 lines (260 loc) · 10.8 KB
/
dot_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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#---------------------------------------------------------------------
# Bash configuration
#---------------------------------------------------------------------
shopt -s globstar
HISTCONTROL=ignoreboth
# ignoreboth: shorthand for ‘ignorespace’ and ‘ignoredups
# ignorespace: lines beginning with a space are not saved
# ignoredups: lines which match the previous history entry to not be saved
HISTFILESIZE=2048 #~4x from a default of 500
shopt -s histappend
# If this needs to be guarded against non-interctive shells then that
# feels like a sign I shouldn't source .bashrc from .bash_profile
# as I've been thinking about
if [ -t 1 ]; then
bind 'set show-all-if-ambiguous on'
bind 'TAB:menu-complete'
bind 'set print-completions-horizontally on'
fi
export CDPATH=".:$HOME/Development"
# export MANPATH="/usr/local/man:$MANPATH"
if command -v vim &> /dev/null ; then
export EDITOR=vim
elif command -v nvim &> /dev/null ; then
export EDITOR=nvim
elif command -v vi &> /dev/null ; then
export EDITOR=vi
fi
# Preferred editor for local and remote sessions
#if [[ -n $SSH_CONNECTION ]]; then
# export VISUAL='vim'
# export EDITOR='vim'
#else
# if [[ $OSTYPE =~ darwin.* ]]; then
# export VISUAL='mvim -f'
# else
# export VISUAL='vim'
# fi
# export EDITOR='vim'
#fi
alias rm='rm -i'
alias cp='cp -i'
# Handle color between macOS and Linux. Will probably bite me on BSD one day...
if [[ $OSTYPE =~ darwin.* ]]; then
alias ls='ls -FG'
alias l1='ls -1FG'
alias ll='ls -FGhl'
alias la='ls -AFG'
alias lal='ls -AFGhl'
alias la1='ls -1AFGh'
else
alias ls='ls -F --color=auto'
alias l1='ls -1F --color=auto'
alias ll='ls -Fhl --color=auto'
alias la='ls -AF --color=auto'
alias lal='ls -AFhl --color=auto'
alias la1='ls -1AFh --color=auto'
fi
alias ls-by-time='find . -type f -print0 | xargs -0 ls -tlr'
alias just='just --unstable'
alias chrome='open -a /Applications/Google\ Chrome.app'
alias firefox='open -a /Applications/Firefox.app'
alias safari='open -a /Applications/Safari.app'
#---------------------------------------------------------------------
# PKG_CONFIG_PATH mgmt
#---------------------------------------------------------------------
if [ -f /usr/bin/pkg-config ]; then
sys_pkg_config=$(/usr/bin/pkg-config --variable pc_path pkg-config)
if [ -v PKG_CONFIG_PATH ]; then
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$sys_pkg_config"
else
PKG_CONFIG_PATH="$sys_pkg_config"
fi
fi
if [ -f $(brew --prefix)/bin/pkg-config ]; then
brew_pkg_config=$($(brew --prefix)/bin/pkg-config --variable pc_path pkg-config)
if [ -v PKG_CONFIG_PATH ]; then
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$brew_pkg_config"
else
PKG_CONFIG_PATH="$brew_pkg_config"
fi
fi
export PKG_CONFIG_PATH
#---------------------------------------------------------------------
# PATH management
#---------------------------------------------------------------------
# This path mgmt is focused on adding things to the PATH that I've wanted to
# install so here we build up a hierarchical ordering of paths and then we
# append any preexisting PATH value to that so that our preferred executables
# are found prior to things on the path before we intereceded
x="${x}:$HOME/bin"
x="${x}:/bin:/sbin"
x="${x}:/usr/bin:/usr/sbin"
x="${x}:/usr/local/bin:/usr/local/sbin"
if [[ $OSTYPE =~ darwin.* ]]; then
x="${x}:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
x="${x}:/Applications/MacVim.app/Contents/bin"
fi
if [[ -n $PATH ]]; then
x="$PATH:$x"
fi
export PATH=$x
unset x
# Now dedup the path
seen=()
IFS=':'
for value in ${PATH[@]}
do
if ! [[ "${seen[@]}" =~ [[:space:]]"$value"[[:space:]] ]]; then
seen+=("$value")
fi
done
dedupped_path=''
for value in "${seen[@]}"
do
dedupped_path+=$value
dedupped_path+=':'
done
export PATH=${dedupped_path%?}
unset seen
unset dedupped_path
IFS=' '
#---------------------------------------------------------------------
# My cobbled keep it out of source control environment variable file
#---------------------------------------------------------------------
# ~/.secretish is a place to put envars that might not be "real secrets"
# but are still probably best left out of source control repositories
[[ -f ~/.secretish ]] && source ~/.secretish
#---------------------------------------------------------------------
# My cobbled .cloudinstance management
# interacts with prompt so keep this above prompt management
#---------------------------------------------------------------------
if [[ -f .cloudinstance ]]; then
H=$(TZ="America/Kentucky/Louisville" date +%H)
when=$(date --date='TZ="America/Kentucky/Louisville" 00:00 today' --utc +"%H:%M")
if (( ${H#0} < 18 )); then
when=$(date --date='TZ="America/Kentucky/Louisville" 18:00 today' --utc +"%H:%M")
fi
TZ='Etc/UTC' sudo shutdown ${when} --no-wall
fi
#---------------------------------------------------------------------
# prompt management
#---------------------------------------------------------------------
if [[ -z $(type -t __git_ps1) ]]; then
source $(brew --prefix)/etc/bash_completion.d/git-prompt.sh
fi
GIT_PS1_SHOWDIRTYSTATE=true
# unstaged (*) and staged (+) changes will be shown next to the branch name
GIT_PS1_SHOWSTASHSTATE=true
# If something is stashed, then a '$' will be shown next to the branch name.
GIT_PS1_SHOWUNTRACKEDFILES=true
# If there're untracked files, then a '%' will be shown next to the branch name.
GIT_PS1_SHOWUPSTREAM="auto verbose"
# see the difference between HEAD and its upstream. A "<" indicates you are
# behind, ">" indicates you are ahead, "<>" indicates you have diverged and "="
# indicates that there is no difference. Adding "verbose" shows number of
# commits ahead/behind (+/-) upstream
GIT_PS1_SHOWCONFLICTSTATE=yes
# The prompt will include "|CONFLICT" when there are unresolved conflicts
GIT_PS1_SHOWCOLORHINTS=true
# colored hint about the current dirty state
if [[ -f ~/.cloudinstance ]]; then
n=$(<~/.cloudinstance)
export PS1='[\e[94m\u\e[0m\e[34m@\e[0m\e[94m$n\e[0m | \e[95m\w\e[0m$(__git_ps1 " | %s")]\n$ '
else
export PS1='[\e[94m\u\e[0m\e[34m@\e[0m\e[94m\h\e[0m | \e[95m\w\e[0m$(__git_ps1 " | %s")]\n$ '
fi
#PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
#PROMPT_COMMAND='__git_ps1 "[\u@\h | \w | \t] "\\\$ "'
#[jaheath@C02G2566MD6R | 13:18:28 | ~/Development/progress/jahtomate | (main|u=)]
#---------------------------------------------------------------------
# https://brew.sh/
#---------------------------------------------------------------------
if [[ $OSTYPE =~ darwin.* ]] && [[ $(command -v brew) ]]; then
eval "$(/usr/local/bin/brew shellenv)"
HOMEBREW_PREFIX="$(brew --prefix)"
fi
if [[ $OSTYPE =~ linux.* ]] && [[ -d /home/linuxbrew/.linuxbrew/ ]]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
HOMEBREW_PREFIX="$(brew --prefix)"
fi
[[ -r "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh" ]] && . "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh"
#if [[ $OSTYPE =~ darwin.* ]]; then
# [[ -r "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh" ]] && . "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh"
#else
# [[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && . /usr/share/bash-completion/bash_completion
#fi
#---------------------------------------------------------------------
# AWS [https://aws.amazon.com/]
#---------------------------------------------------------------------
# https://docs.aws.amazon.com/sdkref/latest/guide/feature-smart-config-defaults.html
export AWS_DEFAULTS_MODE="standard"
# https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html#cli-usage-pagination-clientside
#export AWS_PAGER=bat
#export AWS_PAGER="less --use-color"
#export AWS_PAGER=''
# https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output-format.html
export AWS_DEFAULT_OUTPUT=json
# https://docs.aws.amazon.com/sdkref/latest/guide/feature-region.html
export AWS_REGION=us-east-2
#---------------------------------------------------------------------
# go [https://go.dev/]
#---------------------------------------------------------------------
if [[ -d /usr/local/go/bin ]]; then
export PATH=$PATH:/usr/local/go/bin
fi
#---------------------------------------------------------------------
# habitat
#---------------------------------------------------------------------
export HAB_LICENSE=accept
#---------------------------------------------------------------------
# kubernetes [https://kubernetes.io/]
#---------------------------------------------------------------------
if [[ -d "$HOME/.krew" ]]; then
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
fi
#---------------------------------------------------------------------
# nvm [https://nvm.sh]
#---------------------------------------------------------------------
if [[ -d $HOME/.nvm ]]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # load nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # load bash_completion
fi
#---------------------------------------------------------------------
# ruby [https://www.ruby-lang.org/]
#---------------------------------------------------------------------
if [[ -d $HOME/.rbenv ]]; then
eval "$(rbenv init - --no-rehash bash)"
RUBY_MANPATH="$(rbenv prefix)/share/man"
export MANPATH="$RUBY_MANPATH:$MANPATH"
if [ bc <<< "3.1 <= $(ruby --version | grep -e 'ruby [[:digit:]]\.[[:digit:]]' | cut -d' ' -f 2 )" ]; then
# Ruby 3.1 and above requires OpenSSL 3 (https://github.com/rbenv/ruby-build/wiki)
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@3)"
else
# For Ruby versions 2.x–3.0 (https://github.com/rbenv/ruby-build/wiki)
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])"
fi
fi
#---------------------------------------------------------------------
# rust [https://www.rust-lang.org/]
#---------------------------------------------------------------------
if [[ -f $HOME/.cargo/env ]]; then
. "$HOME/.cargo/env"
export RA_LOG="error" # the logging level for rust analyzer
export RUST_BACKTRACE="0"
#export RUST_LOG="info,manager::file_watcher=trace"
fi
#---------------------------------------------------------------------
# FZF [https://github.com/junegunn/fzf]
#---------------------------------------------------------------------
export FZF_DEFAULT_OPTS="--preview 'bat -n --color=always {}' --color=fg:#f8f8f2,bg:#282a36,hl:#bd93f9 --color=fg+:#f8f8f2,bg+:#44475a,hl+:#bd93f9 --color=info:#ffb86c,prompt:#50fa7b,pointer:#ff79c6 --color=marker:#ff79c6,spinner:#ffb86c,header:#6272a4"
#export FZF_DEFAULT_OPTS="--preview 'bat -n --color=always {}'"
#---------------------------------------------------------------------
# direnv [https://direnv.net/]
# "Make sure it appears even after rvm, git-prompt and other shell
# extensions that manipulate the prompt."
#---------------------------------------------------------------------
if command -v direnv &> /dev/null; then
eval "$(direnv hook bash)"
fi