-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.profile
More file actions
executable file
·372 lines (320 loc) · 12.3 KB
/
.profile
File metadata and controls
executable file
·372 lines (320 loc) · 12.3 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
# .profile
INTERACTIVE=false
if [[ $- == *i* ]]; then
INTERACTIVE=true
fi
################################################################################
# setup paths and env
################################################################################
export PATH=""
# Allow OS X tool to discover typical PATH items first, if possible.
if [[ -e /usr/libexec/path_helper ]]; then
eval "$(/usr/libexec/path_helper -s)"
else
test -d /usr/bin && PATH="$PATH:$_"
test -d /bin && PATH="$PATH:$_"
test -d /usr/sbin && PATH="$PATH:$_"
test -d /sbin && PATH="$PATH:$_"
test -d /usr/local/bin && PATH="$PATH:$_"
test -d /opt/X11/bin && PATH="$PATH:$_"
fi
# Export currently built PATH so the rest of this script has access to them.
if test -e /usr/libexec/path_helper; then
eval "$($_ -s)"
else
export PATH
export MANPATH
fi
ARCH="$(arch)"
export ARCH
# Homebrew puts i386 binaries in /usr/local and arm64 in /opt/homebrew,
# So if we're using arm64 we need to make sure that /opt/homebrew/bin
# comes first in PATH so that the correct binaries are picked up first.
if [[ $ARCH == "arm64" ]]; then
test -d /opt/homebrew/bin && PATH="$_:$PATH"
fi
# Make sure Homebrew utilities override system utilities.
if type brew >/dev/null 2>&1; then
BREW_PREFIX="$(brew --prefix)"
test -d "$BREW_PREFIX/bin" && PATH="$_:$PATH"
test -d "$BREW_PREFIX/sbin" && PATH="$_:$PATH"
BREW_COREUTILS_PREFIX="$BREW_PREFIX/opt/coreutils"
if [[ -d $BREW_COREUTILS_PREFIX ]]; then
test -d "$BREW_COREUTILS_PREFIX/libexec/gnubin" && PATH="$_:$PATH"
test -d "$BREW_COREUTILS_PREFIX/libexec/gnuman" && MANPATH="$_:$MANPATH"
fi
export PATH
export MANPATH
export PYTHONPATH
export BREW_PREFIX
# ensure that brew installed `expect` functions correctly
export TCLLIBPATH="$BREW_PREFIX/lib"
# node version manager
export NVM_DIR="$HOME/.nvm"
BREW_NVM_PREFIX="$BREW_PREFIX/opt/nvm"
if [[ -d $BREW_NVM_PREFIX && -s "$BREW_NVM_PREFIX/nvm.sh" ]]; then
# shellcheck disable=SC1091
source "$BREW_NVM_PREFIX/nvm.sh" --no-use
fi
# go compiler and environment
GOPATH="/opt/gopath/$ARCH"
if [[ ! -d $GOPATH ]]; then
mkdir -p "$GOPATH"
fi
test -d "$GOPATH/bin" && PATH="$PATH:$_"
test -d "$BREW_PREFIX/opt/go/libexec/bin" && PATH="$PATH:$_"
export GOPATH
fi
# Add specific application paths, such as Python, etc...
test -d "$HOME/.cargo/bin" && PATH="$PATH:$_"
test -d "$HOME/.local/bin" && PATH="$PATH:$_"
test -d "$HOME/.log-ninja" && PATH="$PATH:$_"
test -d /usr/local/lib/pkgconfig && PKG_CONFIG_PATH="$_:$PKG_CONFIG_PATH"
# Add npm dev installed dependencies per project
PATH="node_modules/.bin:$PATH"
# Visual Studio Code
test -d "/Applications/Visual Studio Code.app/Contents/Resources/app/bin" && PATH="$PATH:$_"
# Bun
[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun"
if [[ -d "$HOME/.bun" ]]; then
export BUN_INSTALL="$HOME/.bun"
PATH="$BUN_INSTALL/bin:$PATH"
fi
# User utilities
test -d "$HOME/bin" && PATH="$_:$PATH"
export PATH
export PYTHONPATH
export PKG_CONFIG_PATH
USER="$(whoami)"
PLATFORM="$(uname)"
export USER
export PLATFORM
################################################################################
# interactive settings
################################################################################
if $INTERACTIVE; then
# print timestamp and given message
_interactive_log() {
echo "$(date +%H:%M:%S.%N) - $*"
}
set -o emacs
################################################################################
# setup base16-shell -- https://github.com/chriskempson/base16-shell
################################################################################
_interactive_log "setting up base16-shell"
BASE16_SHELL="$HOME/.config/base16-shell/"
# shellcheck disable=SC1091
[ -n "$PS1" ] && [ -s "$BASE16_SHELL/profile_helper.sh" ] && source "$BASE16_SHELL/profile_helper.sh"
################################################################################
# terminal history
################################################################################
HISTFILE="$HOME/.$(basename "$SHELL")_history.$(uname -s)"
export HISTFILE
export HISTCONTROL=ignoredups:erasedups
export TERMINAL_HISTORY_SIZE="100000"
export HISTSIZE="$TERMINAL_HISTORY_SIZE"
export HISTFILESIZE="$TERMINAL_HISTORY_SIZE"
export SAVEHIST="$TERMINAL_HISTORY_SIZE"
################################################################################
# direnv setup
################################################################################
if command -v direnv >/dev/null 2>&1; then
_interactive_log "setting up direnv"
eval "$(direnv hook zsh)"
fi
################################################################################
# setup terminal colors and editors
################################################################################
# setup editors (default to vim)
export EDITOR=vim
export CVSEDITOR=vim
export XEDITOR=vim
export IGNOREEOF=0
alias mm='mamba '
alias e='vim . '
alias edit='vim '
ew() { type "$1" >/dev/null 2>&1 && vim "$(command -v "$1")"; }
if type code >/dev/null 2>&1; then
alias e='code -a . '
alias edit='code '
ew() { type "$1" >/dev/null 2>&1 && code "$(command -v "$1")"; }
elif type subl >/dev/null 2>&1; then
alias e='subl -a . '
alias edit='subl '
ew() { type "$1" >/dev/null 2>&1 && subl "$(command -v "$1")"; }
fi
vman() { man "$@" | col -bx | vim -; }
# setup man
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
export CHTSH_QUERY_OPTIONS="style=lovelace"
################################################################################
# setup aliases and functions
################################################################################
alias g='open -na "GitKraken" --args -p $(pwd) '
alias st='stree '
alias bc='bc -l '
alias profile='valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes '
alias memcheck='valgrind --tool=memcheck --leak-check=yes -show-reachable=yes -fno-inline --logfile=memcheck.log '
alias pygmentize='pygmentize -O bg=dark'
fa() {
local PARAMS PARAM
local INCLUDE_TESTS=0
for PARAM in "$@"; do
if [[ $PARAM == "--tests" ]]; then
INCLUDE_TESTS=1
else
PARAMS="${PARAMS} \"${PARAM}\""
fi
done
if [[ $INCLUDE_TESTS == "0" ]]; then
PARAMS="${PARAMS} -g '!**/tests'"
fi
run rg \
--type-not svg \
--trim \
--sort modified \
--smart-case \
--pretty \
--hidden \
--max-columns "$(stty size | cut -d' ' -f2)" "${PARAMS}"
}
alias ltr='ls -l -tmodified -snew '
alias pm='porsmo '
if type npm >/dev/null 2>&1; then
linked() {
npm ls -g --depth=0 --link=true "$@" 2>/dev/null
}
fi
# git shortcuts
alias s='git s -u '
# This ipython alias prevents `ipython notebook` from working correctly.
# alias ipython='ipython --no-banner --no-confirm-exit '
if type ncftp >/dev/null 2>&1; then alias ftp='ncftp '; fi
if type share >/dev/null 2>&1; then alias shares='share '; fi
if type htop >/dev/null 2>&1; then alias top='htop '; fi
export RSYNC_RSH=rsh # use ssh over rsync
alias ssh='ssh -Y -C ' # use compression over ssh connections
test -f "$HOME/.ssh/id_rsa" && /usr/bin/ssh-add -K >/dev/null 2>&1 # use keychain for ssh keys
fuck() {
if die "$1"; then
echo
echo " (╯°□°)╯︵$(echo "$1" | flip 2>/dev/null)"
echo
fi
}
lw() {
local LOC
local FINFO
local REAL
LOC="$(command -v "$1")"
echo "$LOC"
FINFO="$(file -h "$LOC")"
if [[ $FINFO =~ "symbolic link to" ]]; then
# shellcheck disable=SC2001
SYLOC="$(echo "$FINFO" | sed 's@.*symbolic link to\s*\(.*\)@\1@')"
if [[ $SYLOC != /* ]]; then
LOC="$(dirname "$LOC")/$SYLOC"
else
LOC="$SYLOC"
fi
echo "$LOC"
if type realpath >/dev/null 2>&1; then
REAL="$(realpath "$LOC")"
if [[ $REAL != "$LOC" ]]; then
echo "$REAL"
fi
fi
fi
}
# shellcheck disable=SC2120
hist() {
if [[ $SHELL =~ "zsh" ]]; then
if [[ -n $* ]]; then
history 1 | grep -E "^\\s*[0-9]*\\s*.*$*.*$"
else
history 1
fi
elif [[ $SHELL =~ "bash" ]]; then
history | grep -E "^\\s*[0-9]*\\s*.*$*.*$"
fi
}
# use gnu-sed if available
if type gsed >/dev/null 2>&1; then
alias sed='gsed '
fi
# shellcheck source=.docker_functions
# shellcheck disable=SC1091
test -f "$HOME/.docker_functions" && source "$_"
################################################################################
# source any local configuration files
################################################################################
IFS=$'\n'
[[ $SHELL =~ "zsh" ]] && unsetopt nomatch
for I in $(/bin/ls -1 ~/.profile_* 2>/dev/null); do
_interactive_log "sourcing $(basename "$I")"
# shellcheck source=$I
# shellcheck disable=SC1091
source "$I"
done
[[ $SHELL =~ "zsh" ]] && setopt nomatch
IFS=' '
################################################################################
# setup shell_control
################################################################################
# shellcheck source=.shell_control
# shellcheck disable=SC1091
source "$HOME/.shell_control" || echo "$(tput bold)error: ~/.shell_control not installed!$(tput sgr0)" >&2
################################################################################
# always assume we want our default mamba python environment
################################################################################
_interactive_log "setting up python environment"
test -f "$HOME/.pythonrc.py" && PYTHONSTARTUP="$_"
export PYTHONSTARTUP
export VIRTUAL_ENV_DISABLE_PROMPT=1
export MAMBA_ROOT_PREFIX="$HOME/miniforge3"
__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
unset __conda_setup
if [ -f "$HOME/miniforge3/etc/profile.d/mamba.sh" ]; then
. "$HOME/miniforge3/etc/profile.d/mamba.sh"
fi
################################################################################
# general environment setup
################################################################################
_interactive_log "setting up envrionment"
# Override prezto's grep configuration
alias grep='nocorrect grep --color=auto'
export GREP_COLOR='1;35;40'
# I hate autocorrection in CLI, disable it because prezto enables it.
alias cd='nocorrect cd'
# Finally setup ls to ensure we override any aliases, like from prezto.
if type exa >/dev/null 2>&1; then
alias ls='exa '
alias ll='ls -lg --git --header --group-directories-first --git-ignore --time-style="long-iso" '
else
alias ls='ls -hF --color=auto'
alias ll='ls -l '
fi
if type dircolors >/dev/null 2>&1; then
eval "$(dircolors -b "$HOME/.dircolors" 2>/dev/null)" # sets LS_COLORS
fi
alias l='ls '
export CLICOLOR=1
fi # if $INTERACTIVE
# Make sure user utilities always take precedence
test -d "$HOME/bin" && PATH="$_:$PATH"
export PATH