-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.sh_env
242 lines (213 loc) · 6.76 KB
/
.sh_env
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
#!/not/executable/bash
# interactive environment that should be shared by bash and zsh
# commands that must be run just once for each new terminal
# generally, this is environment variables
# if your command needs to be run for each new *shell* use ~/.sh_rc
# basics are already handled in .(z)profile, for noninteractive shells
# ensure access to private dotfiles
. "$HOME"/.sh_lib/functions.d/has.sh
if has private-dotfiles-check && ! private-dotfiles-check; then
private-dotfiles-mount
fi
# save/restore our $PATH, so that we can (re-)source this file idempotently
# currently this is the only environment variable we modify (rather than
# overwrite), but we should do this for all such
if command -v deactivate >/dev/null; then
deactivate
fi
if [ -z "$__orig_PATH" ]; then
export __orig_PATH="$PATH"
else
PATH="$__orig_PATH"
fi
# MacOS:
if [ -x /usr/libexec/path_helper ]; then
eval "$(/usr/libexec/path_helper -s)"
fi
# note: "MACHTYPE" is the compile-time CPU architecture
export CPUTYPE OSTYPE
CPUTYPE="$(uname -m)"
OSTYPE="$(uname -s | tr '[:upper:]' '[:lower:]')"
# extra shell environment for work
. "$HOME"/.sh_lib/functions.d/trysource.sh
trysource ~/private-dotfiles/.sh_env
export HOMEBREW
HOMEBREW="$(command -v brew)"
export HOMEBREW_VERBOSE=1
export HOMEBREW_DEVELOPER=1
export HOMEBREW_PREFIX="/opt/homebrew"
export HOMEBREW_CELLAR="$HOMEBREW_PREFIX/Cellar"
export HOMEBREW_REPOSITORY="$HOMEBREW_PREFIX"
# this makes brew-desc not complain:
export HOMEBREW_EVAL_ALL=1
if echo "$OSTYPE" | grep -q '^darwin'; then
# override crappy macos userspace with homebrew "gnubin"
export PATH="$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin:$HOMEBREW_PREFIX/libexec/gnubin:$PATH"
export MANPATH="$HOMEBREW_PREFIX/share/man:$HOMEBREW_PREFIX/libexec/gnuman:$MANPATH"
export INFOPATH="$HOMEBREW_PREFIX/share/info:$HOMEBREW_PREFIX/libexec/gnuinfo:$INFOPATH"
else # linux
# append homebrew -- prepending caused too many issues
# instead of: eval "$("$HOMEBREW" shellenv)"
export PATH="${PATH+$PATH:}$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin"
export MANPATH="${MANPATH+$MANPATH:}$HOMEBREW_PREFIX/share/man:"
export INFOPATH="${INFOPATH+$INFOPATH:}$HOMEBREW_PREFIX/share/info:"
fi
warn() { echo "[1;33mWARNING: [22m$*[0m" >&2; }
abspath() { (cd "$1" && pwd); } # absolute, but avoid dereferencing symlinks
if has nproc; then
export HOMEBREW_MAKE_JOBS="$(($(nproc) * 3))"
else
warn "please brew install coreutils"
fi
# set PATH so it includes user's personal bin if it exists (or is created)
export PATH=~/.local/bin:~/private-dotfiles/bin:~/bin:"$PATH"
export GOPATH=~/prefix/gopath
export GDK_SCALE=2
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
export CLOUDSDK_ROOT_DIR="$HOMEBREW_PREFIX/Caskroom/google-cloud-sdk"
export CLOUDSDK_PYTHON_PREFIX="$CLOUDSDK_ROOT_DIR/latest/google-cloud-sdk/platform/bundledpythonunix"
export CLOUDSDK_PYTHON="$CLOUDSDK_PYTHON_PREFIX/bin/python3"
export CLOUDSDK_PYTHON_SITEPACKAGES=1
export USE_GKE_GCLOUD_AUTH_PLUGIN=1
# https://docs.sentry.io/product/sentry-basics/dsn-explainer/
export SENTRY_INSTRUMENTATION=1
export SENTRY_POST_MERGE_AUTO_UPDATE=1
export SENTRY_SPA_DSN=https://863de587a34a48c4a4ef1a9238fdb0b1@o19635.ingest.sentry.io/5270453
. "$HOME"/.sh_lib/functions.d/bootstamp.sh
export BOOT
BOOT=$(bootstamp)
# bootstrap homebrew deps
#xargs -tr brew install < .config/bukzor-dotfiles/homebrew.list
#MY PREFERENCES ==============================================================
export EDITOR=vim
export VISUAL=$EDITOR
export GIT_EDITOR=$EDITOR
export P4DIFFOPTS="-u --color"
export P4DIFF=~/bin/p4-difftool
export PYTHONSTARTUP=~/.pythonrc.py
export EMAIL
if has git; then
EMAIL="$(git config user.email)"
fi
if [ -z "$LANG" ]; then
export LANG='en_US.UTF-8'
fi
# Set the default Less options.
export LESS='-XFR -i -M -w -z-4'
export PAGER=less
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Browser
if echo "$OSTYPE" | grep -q '^darwin'; then
export BROWSER='open'
export SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
fi
#unmap CTRL-S and CTRL-Q
if tty >/dev/null; then
stty -ixon -ixoff
fi
psget() {
column="$1"
pid="$2"
ps -o "$column"= -p "$pid" |
tr -d " "
}
# fix up TERM values
# get the session-leader's parent
if ! terminal="$(psget ppid "$(psget sess $$)")" || [ -z "$terminal" ]; then
: refuse the tempation to guess what went wrong
elif [ "$terminal" -gt 0 ]; then
#use the basename of its arg[0]
terminal="$(basename "$(head -zn1 "/proc/$terminal/cmdline" | tr -d '\0')")"
else
# if our session-leader doesn't have a real parent (pid:0) then we're running as init
terminal=init
fi
case "$terminal" in
lxterminal | gnome-terminal | xfce4-terminal)
export TERM=xterm-256color
;;
tmux | "tmux: server")
export TERM=xterm-256color
;;
init)
if [ "$TERM" != "linux" ]; then
warn 'unknown terminal: "'"$terminal"'" (TERM='"$TERM)"
fi
;;
'')
if ! [ "$TERM" ]; then
export TERM=xterm-256color
warn '$TERM unset. Guessing: TERM='"$TERM"
fi
;;
*)
if ! echo "$OSTYPE" | grep -q '^darwin' &&
! echo "$TERM" | grep -Eq '^(xterm|screen)-256color$'; then
warn 'unknown terminal: "'"$terminal"'" (TERM='"$TERM)"
fi
;;
esac
# Further environment
export PREFIX
PREFIX="$(abspath "$HOME/../..")"
export GEM_HOME=~/prefix/rubygems
export REPO=$HOME/repo
# ask terminfo whether we have a color terminal
# tput is more appropriate for this but harder to use
if has infocmp; then
if infocmp -1GLx | grep -Eq '^\s*(Tc|setrgbf)[=,]'; then
export CLICOLOR=truecolor
export COLORTERM=truecolor
elif infocmp -1GLx | grep -Eq '^\s*(set_a_foreground)[=,]'; then
export CLICOLOR=1
export COLORTERM=1
else
unset CLICOLOR
unset COLORTERM
fi
export TERM_ITALICS=1
fi
# My very own python!
activate() { trysource ~/venv/"$USER"-venv/bin/activate; }
activate
export TMPDIR
# NB: macos date(1) doesn't support -I nor -Id
date="$(date -Idate)"
for TMPDIR in \
"$TMPDIR" \
"$PREFIX/tmp/$USER/$BOOT/$date" \
"/tmp/$USER/$BOOT/$date" \
"/tmp" \
"$HOME/tmp/$BOOT/$date" \
"$HOME/tmp"; do
if [ "$TMPDIR" ]; then
mkdir -p "$TMPDIR" 2>/dev/null
chmod -f 700 "$TMPDIR"
if [ -d "$TMPDIR" ] && [ -w "$TMPDIR" ]; then
break
fi
fi
done
unset date
if [ "$TMPDIR" ] && [ -d "$TMPDIR" ] && [ -w "$TMPDIR" ]; then
TMPDIR="$(abspath "$TMPDIR")"
else
unset TMPDIR
warn 'No writable TMPDIR!'
fi
. "$HOME"/.sh_plugins.d/xdg.sh
# pyenv makes too many things derp
## export PYENV_ROOT="$XDG_CACHE_HOME/pyenv"
## export PATH="$PYENV_ROOT/bin:$PATH"
## if has pyenv; then
## eval "$(pyenv init -)"
## fi
# added by travis gem
trysource ~/.travis/travis.sh
if has aactivator; then
eval "$(aactivator init)"
fi
trysource "$HOME/.cargo/env"
# vim:et:sw=2:sts=2: