-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_bash_profile.tmpl
More file actions
394 lines (332 loc) · 11.5 KB
/
dot_bash_profile.tmpl
File metadata and controls
394 lines (332 loc) · 11.5 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
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
BREW_BIN=""
if [ -x "/opt/homebrew/bin/brew" ]; then
BREW_BIN="/opt/homebrew/bin/brew"
elif [ -x "/usr/local/bin/brew" ]; then
BREW_BIN="/usr/local/bin/brew"
elif command -v brew >/dev/null 2>&1; then
BREW_BIN="$(command -v brew)"
fi
if [ -n "$BREW_BIN" ]; then
eval "$("$BREW_BIN" shellenv)"
BREW_PREFIX="$("$BREW_BIN" --prefix)"
if [ -d "$BREW_PREFIX/opt/coreutils/libexec/gnubin" ]; then
PATH="$BREW_PREFIX/opt/coreutils/libexec/gnubin:${PATH}"
fi
fi
path_prepend() {
[ -n "$1" ] || return
case ":$PATH:" in
*":$1:"*) ;;
*) PATH="$1${PATH:+:$PATH}" ;;
esac
}
path_append() {
[ -n "$1" ] || return
case ":$PATH:" in
*":$1:"*) ;;
*) PATH="${PATH:+$PATH:}$1" ;;
esac
}
path_dedupe() {
local new_path=""
local path_entry
local IFS=':'
for path_entry in $PATH; do
[ -n "$path_entry" ] || continue
case ":$new_path:" in
*":$path_entry:"*) ;;
*) new_path="${new_path:+$new_path:}$path_entry" ;;
esac
done
PATH="$new_path"
}
path_prepend "/usr/sbin"
path_prepend "/usr/bin"
path_prepend "/usr/local/sbin"
path_prepend "/usr/local/bin"
# dart-lang's pub installs executables here
path_append "$HOME/.pub-cache/bin"
path_append "$HOME/.girpl/bin"
# Go configuration for go modules
export GO111MODULE="auto" # this may or may not have to be set, or can be set to "auto"
if [ -z "${GOROOT:-}" ]; then
for goroot_candidate in /usr/lib/go-*; do
if [ -x "$goroot_candidate/bin/go" ]; then
GOROOT="$goroot_candidate"
fi
done
unset goroot_candidate
fi
if [ -n "${GOROOT:-}" ] && [ -x "$GOROOT/bin/go" ]; then
path_prepend "$GOROOT/bin"
fi
export DART_FLAGS="--checked --load_deferred_eagerly"
export DARTIUM_EXPIRATION_TIME=1577836800
export GOPATH=$HOME/code/gopath
export CHEZMOI_GH_HOST='{{ if hasKey . "gh" }}{{ .gh.host }}{{ else if ne (env "CHEZMOI_GH_HOST") "" }}{{ env "CHEZMOI_GH_HOST" }}{{ else }}github.com{{ end }}'
export CHEZMOI_GH_CONFIG_DIR="${CHEZMOI_GH_CONFIG_DIR:-$HOME/.config/gh-personal}"
{{- if eq .profile "work" }}
export AI_TERM_CMD="agent"
{{- else }}
export AI_TERM_CMD="opencode"
{{- end }}
path_append "$GOPATH/bin"
export GOPRIVATE=github.com/Workiva
path_append "/usr/local/bin/nimrod/bin"
{{- if eq .chezmoi.os "darwin" }}
path_prepend "$(/usr/libexec/java_home -v 11 2>/dev/null)/bin"
path_append "/usr/local/texlive/2021basic/bin/universal-darwin"
{{- end }}
{{- if eq .chezmoi.os "windows" }}
path_append "/c/Program Files/PowerShell/7"
{{- end }}
{{- if eq .profile "work" }}
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then
source ~/.wk/profile
fi
{{- end }}
path_prepend "$HOME/.local/bin"
{{- if eq .profile "personal" }}
path_append "$HOME/.opencode/bin"
export CHEZMOI_GH_TOKEN_OP_REF='{{ if hasKey . "gh" }}{{ .gh.tokenOpRef }}{{ else }}{{ env "CHEZMOI_GH_TOKEN_OP_REF" }}{{ end }}'
{{- end }}
{{- if ne .chezmoi.os "windows" }}
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ] && command -v mise >/dev/null 2>&1; then
eval "$(mise activate bash)"
fi
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ] && command -v zoxide >/dev/null 2>&1; then
eval "$(zoxide init bash)"
fi
{{- end }}
# HACK: to get conda 4.7.5 working again
# Which broke after upgrading from 4.5.11 using:
# conda update -n base conda
#
# from https://github.com/conda/conda/issues/8867#issuecomment-508820119:
# brew install libarchive then set LIBARCHIVE.
if [ -n "${BREW_PREFIX:-}" ] && [ -f "$BREW_PREFIX/opt/libarchive/lib/libarchive.13.dylib" ]; then
export LIBARCHIVE="$BREW_PREFIX/opt/libarchive/lib/libarchive.13.dylib"
fi
# alias to enable some dev commands that are still using the pub command.
alias pub='dart pub'
alias dart2js='dart compile js'
oprompt () {
local chezmoi_source
local script_path
if ! command -v chezmoi >/dev/null 2>&1; then
printf 'oprompt: chezmoi is not installed.\n' >&2
return 1
fi
if ! chezmoi_source="$(chezmoi source-path 2>/dev/null)"; then
printf 'oprompt: unable to determine chezmoi source path.\n' >&2
return 1
fi
script_path="$chezmoi_source/scripts/oprompt.sh"
if [ ! -x "$script_path" ]; then
printf 'oprompt: missing executable script: %s\n' "$script_path" >&2
return 1
fi
"$script_path" "$@"
}
aprompt () {
oprompt "$@"
}
ghpersonalauth () {
local config_dir
config_dir="${CHEZMOI_GH_CONFIG_DIR:-$HOME/.config/gh-personal}"
mkdir -p "$config_dir"
GH_CONFIG_DIR="$config_dir" command gh auth login -h github.com -p ssh "$@"
GH_CONFIG_DIR="$config_dir" command gh auth status
}
gh () {
local chezmoi_source
if [ -z "${GH_CONFIG_DIR:-}" ] && command -v chezmoi >/dev/null 2>&1; then
if chezmoi_source="$(chezmoi source-path 2>/dev/null)"; then
case "$PWD/" in
"$chezmoi_source"/*|"$chezmoi_source"/)
GH_CONFIG_DIR="$CHEZMOI_GH_CONFIG_DIR" command gh "$@"
return $?
;;
esac
fi
fi
command gh "$@"
}
tmuxdev () {
local chezmoi_source
local script_path
if ! command -v tmux >/dev/null 2>&1; then
printf 'tmuxdev: tmux is not installed.\n' >&2
return 1
fi
if ! command -v chezmoi >/dev/null 2>&1; then
printf 'tmuxdev: chezmoi is not installed.\n' >&2
return 1
fi
if ! chezmoi_source="$(chezmoi source-path 2>/dev/null)"; then
printf 'tmuxdev: unable to determine chezmoi source path.\n' >&2
return 1
fi
script_path="$chezmoi_source/scripts/tmux-dev-session.sh"
if [ ! -x "$script_path" ]; then
printf 'tmuxdev: missing executable script: %s\n' "$script_path" >&2
return 1
fi
"$script_path" "$@"
}
{{ if eq .profile "work" }}
chezwork () {
local source_dir="$HOME/.local/share/chezmoi-work"
local config_file="$HOME/.config/chezmoi-work/chezmoi.toml"
if ! command -v chezmoi >/dev/null 2>&1; then
printf 'chezwork: chezmoi is not installed.\n' >&2
return 1
fi
if [ ! -d "$source_dir" ]; then
printf 'chezwork: work source missing: %s\n' "$source_dir" >&2
printf 'chezwork: bootstrap it with `chezmoi init -S %s -c %s <repo>`.\n' "$source_dir" "$config_file" >&2
return 1
fi
if [ ! -f "$config_file" ]; then
printf 'chezwork: work config missing: %s\n' "$config_file" >&2
return 1
fi
chezmoi -S "$source_dir" -c "$config_file" "$@"
}
{{- end }}
# bash completions
if command -v brew >/dev/null 2>&1; then
[[ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]] && . "$(brew --prefix)/etc/profile.d/bash_completion.sh"
fi
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
source ~/.tig-completion.bash
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then
if [ -n "${BREW_PREFIX:-}" ] && [ -f "$BREW_PREFIX/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc" ]; then
source "$BREW_PREFIX/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc"
fi
if [ -n "${BREW_PREFIX:-}" ] && [ -f "$BREW_PREFIX/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" ]; then
source "$BREW_PREFIX/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc"
fi
fi
if command -v locale >/dev/null 2>&1 && locale -a 2>/dev/null | grep -qi '^en_US\.utf\-\?8$'; then
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
elif command -v locale >/dev/null 2>&1 && locale -a 2>/dev/null | grep -qi '^C\.UTF\-\?8$'; then
LANG="C.UTF-8"
LC_ALL="C.UTF-8"
fi
# Git and SVN
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then
export EDITOR='nvim'
git config --global color.ui true
fi
# Maven
export MAVEN_OPTS="-Xmx4096m -Xss1024m"
# Ant
export ANT_OPTS="-Xms512m -Xmx1024m"
ant () { command ant -logger org.apache.tools.ant.listener.AnsiColorLogger "$@" | sed 's/2;//g' ; }
# todo.txt
export TODOTXT_DEFAULT_ACTION=ls
if [ -n "${BREW_PREFIX:-}" ] && [ -f "$BREW_PREFIX/etc/bash_completion.d/todo_completion" ]; then
source "$BREW_PREFIX/etc/bash_completion.d/todo_completion"
fi
alias todo='todo.sh -a'
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then
complete -F _todo todo
fi
# Oh My Posh — https://ohmyposh.dev/
{{- if ne .chezmoi.os "windows" }}
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ] && [ -f "$HOME/.config/oh-my-posh/shell-init.sh" ]; then
# shellcheck source=/dev/null
. "$HOME/.config/oh-my-posh/shell-init.sh" bash
fi
{{- end }}
[ -r ~/.extra ] && source ~/.extra
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
if [ -x "$HOME/miniforge3/bin/conda" ]; then
__conda_setup="$("$HOME/miniforge3/bin/conda" 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$HOME/miniforge3/etc/profile.d/conda.sh" ]; then
. "$HOME/miniforge3/etc/profile.d/conda.sh"
else
export PATH="$HOME/miniforge3/bin:$PATH"
fi
fi
fi
unset __conda_setup
# <<< conda initialize <<<
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then
if declare -f conda >/dev/null 2>&1; then
conda activate
fi
fi
# Added by Toolbox App
path_append "/usr/local/bin"
if [ -n "${BREW_PREFIX:-}" ] && [ -d "$BREW_PREFIX/opt/mysql-client/bin" ]; then
path_prepend "$BREW_PREFIX/opt/mysql-client/bin"
fi
PATH="$HOME/.local/bin:${PATH}"
path_dedupe
export PATH
# just(1): load static completions, then proj:: wrapper — must run *last* so
# ~/.extra, conda, and bash-completion's on-demand `just` loader cannot clobber
# `complete -F _just_with_proj_dynamic`. Re-assert on each prompt if something
# replaced the registration (some loaders reset to stock `_just` / `_clap_complete_just`).
_just_static_candidates=(
"${HOME}/.local/share/bash-completion/completions/just"
"${BREW_PREFIX:-}/share/bash-completion/completions/just"
"${BREW_PREFIX:-}/etc/bash_completion.d/just"
)
for _justc in "${_just_static_candidates[@]}"; do
if [ -r "$_justc" ]; then
# shellcheck source=/dev/null
. "$_justc"
break
fi
done
unset _justc _just_static_candidates
# If no on-disk completion file ran, define stock completer from the `just` on PATH
# (Homebrew/mise layouts vary; modern just uses `_clap_complete_just`, not `_just`).
if command -v just >/dev/null 2>&1; then
if ! declare -F _just >/dev/null 2>&1 && ! declare -F _clap_complete_just >/dev/null 2>&1; then
eval "$(JUST_COMPLETE=bash just)"
fi
fi
if command -v chezmoi >/dev/null 2>&1 && command -v just >/dev/null 2>&1; then
_jp_comp="$(chezmoi source-path 2>/dev/null)/scripts/just-proj-completion.bash"
if [ -r "${_jp_comp:-}" ]; then
# shellcheck source=/dev/null
. "$_jp_comp"
fi
unset _jp_comp
fi
if [ -z "${_CHEZ_JUST_PROJ_PROMPT_INIT:-}" ]; then
_chez_reassert_just_proj_completion() {
command -v chezmoi >/dev/null 2>&1 || return 0
local _p _c
_p="$(chezmoi source-path 2>/dev/null)" || return 0
_c="${_p}/scripts/just-proj-completion.bash"
[ -r "$_c" ] || return 0
if complete -p just 2>/dev/null | grep -qF '_just_with_proj_dynamic'; then
return 0
fi
# shellcheck source=/dev/null
. "$_c"
}
case $- in *i*)
PROMPT_COMMAND="_chez_reassert_just_proj_completion${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
;;
esac
_CHEZ_JUST_PROJ_PROMPT_INIT=1
fi