-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bash_profile
More file actions
151 lines (126 loc) · 5.4 KB
/
Copy path.bash_profile
File metadata and controls
151 lines (126 loc) · 5.4 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
# =============================================================================
# Shell
# =============================================================================
export BASH_SILENCE_DEPRECATION_WARNING=1
# History — longer scrollback, no duplicates, append across sessions
export HISTSIZE=10000
export HISTFILESIZE=20000
HISTCONTROL=ignoredups:erasedups
shopt -s histappend
export PROMPT_COMMAND='history -a'
# =============================================================================
# Bash-it
# =============================================================================
if [[ -d $HOME/.bash_it ]]; then
export BASH_IT=$HOME/.bash_it
export BASH_IT_THEME=$HOME/.spazzy757.theme.bash
unset MAILCHECK
export IRC_CLIENT='irssi'
export TODO="t"
export SCM_CHECK=true
export SHORT_HOSTNAME=$(hostname -s)
source $BASH_IT/bash_it.sh
fi
# =============================================================================
# PATH
# =============================================================================
# Add a dir to PATH only if it exists and isn't already present — avoids the
# duplicate/dead entries you get when this file is sourced more than once.
_prepend_path() { [ -d "$1" ] && case ":$PATH:" in *":$1:"*) ;; *) PATH="$1:$PATH" ;; esac; }
_append_path() { [ -d "$1" ] && case ":$PATH:" in *":$1:"*) ;; *) PATH="$PATH:$1" ;; esac; }
_prepend_path /usr/local/sbin
_prepend_path /usr/local/opt/curl/bin
_prepend_path "$HOME/.local/bin"
_prepend_path "$HOME/.cargo/bin"
_prepend_path "$HOME/.poetry/bin"
_prepend_path "$HOME/.krew/bin"
_prepend_path "$HOME/.kubectx"
_prepend_path "$HOME/.jenv/bin"
export GOPATH=$HOME/go
export BUN_INSTALL="$HOME/.bun"
_append_path "$HOME/.linkerd2/bin"
_append_path /usr/local/go/bin
_append_path "$GOPATH/bin"
_prepend_path "$BUN_INSTALL/bin"
export PATH
# =============================================================================
# Languages
# =============================================================================
# Python — shims on PATH up front; pyenv init deferred to first use to avoid slow startup
export PYENV_ROOT="$HOME/.pyenv"
_prepend_path "$PYENV_ROOT/shims"
_prepend_path "$PYENV_ROOT/bin"
unset -f _prepend_path _append_path
if command -v pyenv 1>/dev/null 2>&1; then
pyenv() {
unset -f pyenv
eval "$(command pyenv init - --no-rehash)" # --no-rehash skips a ~200ms shim rebuild
pyenv "$@"
}
fi
export GIT_INTERNAL_GETTEXT_TEST_FALLBACKS=1 # suppress gettext.sh warning from pyenv
# Rust
. "$HOME/.cargo/env"
# Java
if command -v jenv 1>/dev/null 2>&1; then
eval "$(jenv init -)"
fi
# JavaScript — NVM lazy loaded on first use to avoid slow shell startup
export NVM_DIR="$HOME/.nvm"
_load_nvm() {
unset -f nvm node npm npx yarn pnpm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
}
nvm() { _load_nvm; nvm "$@"; }
node() { _load_nvm; node "$@"; }
npm() { _load_nvm; npm "$@"; }
npx() { _load_nvm; npx "$@"; }
yarn() { _load_nvm; yarn "$@"; }
pnpm() { _load_nvm; pnpm "$@"; }
# =============================================================================
# Completions
# =============================================================================
# Cache completions by binary mtime — avoids a subprocess on every shell open
_cache_completion() {
local name="$1" cache="$HOME/.cache/${1}-completion.bash"
local bin; bin=$(command -v "$name" 2>/dev/null) || return
if [ ! -f "$cache" ] || [ "$bin" -nt "$cache" ]; then
mkdir -p "$HOME/.cache"
shift; "$@" > "$cache" 2>/dev/null || rm -f "$cache"
fi
[ -f "$cache" ] && source "$cache"
}
_cache_completion kubectl kubectl completion bash
_cache_completion scw scw autocomplete script shell=bash
_cache_completion stern stern --completion=bash
unset -f _cache_completion
complete -o default -F __start_kubectl k
complete -C /usr/bin/terraform terraform
# macOS — Homebrew git completion
if command -v brew 1>/dev/null 2>&1; then
[ -f "$(brew --prefix)/etc/bash_completion.d/git-completion.bash" ] && \
. "$(brew --prefix)/etc/bash_completion.d/git-completion.bash"
fi
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
[ -f $HOME/.git-completion.bash ] && source $HOME/.git-completion.bash
[ -f $HOME/.minikube.completion.sh ] && source $HOME/.minikube.completion.sh
[ -f $HOME/.fzf.bash ] && source $HOME/.fzf.bash
[ -f /usr/share/doc/fzf/examples/key-bindings.bash ] && source /usr/share/doc/fzf/examples/key-bindings.bash
export FZF_COMPLETION_OPTS='--border --info=inline'
# Google Cloud SDK
[ -f $HOME/google-cloud-sdk/path.bash.inc ] && . $HOME/google-cloud-sdk/path.bash.inc
[ -f $HOME/google-cloud-sdk/completion.bash.inc ] && . $HOME/google-cloud-sdk/completion.bash.inc
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
# =============================================================================
# Editor
# =============================================================================
export VISUAL=nvim
export EDITOR="$VISUAL"
export VIMINIT="source $HOME/.config/nvim/init.lua"
# =============================================================================
# Misc
# =============================================================================
export DOCKER_BUILDKIT=1
[ -f $HOME/.aliases ] && source $HOME/.aliases
[ -f $HOME/.protected ] && source $HOME/.protected