-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared_shell_configs
More file actions
166 lines (138 loc) · 4.35 KB
/
shared_shell_configs
File metadata and controls
166 lines (138 loc) · 4.35 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
# Preferred editor for local and remote sessions
export EDITOR="/usr/bin/env emacs"
if [ "$(arch)" = "arm64" ]; then
export ARCH="arm64"
fi
mkcd() {
mkdir -p -- "$1" &&
cd -P -- "$1"
}
# Homebrew shellenv
if [ "$ARCH" = "arm64" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
else
if [ "$CODESPACES" ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
else
eval "$(/usr/local/bin/brew shellenv)"
fi
fi
# Extend PATH
export PATH="$PATH:/usr/local/sbin"
export DOTFILESDIR="$HOME/dotfiles"
if [ "$CODESPACES" ]; then
export DOTFILESDIR="/workspaces/.codespaces/.persistedshare/dotfiles"
eval "$ENV_VARS"
fi
# pipenv should be created in the project dir
export PIPENV_VENV_IN_PROJECT=1
# Poetry
export PATH="$HOME/.local/bin:$PATH"
# Python Tcl-Tk options for pyenv
export PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I/usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'"
export TK_SILENCE_DEPRECATION=1
# Lazy-load version managers: defers eval until first use
if command -v pyenv 1>/dev/null 2>&1; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export ZSH_PYENV_VIRTUALENV=true
pyenv() {
unset -f pyenv
eval "$(command pyenv init --path)"
pyenv "$@"
}
fi
if command -v nodenv 1>/dev/null 2>&1; then
export NODENV_ROOT="$HOME/.nodenv"
export PATH="$NODENV_ROOT/bin:$PATH"
nodenv() {
unset -f nodenv
eval "$(command nodenv init -)"
nodenv "$@"
}
fi
if command -v rbenv 1>/dev/null 2>&1; then
export RBENV_ROOT="$HOME/.rbenv"
export PATH="$RBENV_ROOT/bin:$PATH"
rbenv() {
unset -f rbenv
eval "$(command rbenv init -)"
rbenv "$@"
}
fi
# GNU dependencies for building some Homebrew formulae, like Emacs
export PATH="$HOMEBREW_PREFIX/opt/gnu-tar/libexec/gnubin:$PATH"
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
# Brew curl first in path
export PATH="$HOMEBREW_PREFIX/opt/curl/bin:$PATH"
notify() {
local msg
local result
local curl_exit
msg="$*"
result=$(curl --show-error --silent -o /dev/null -w '%{http_code}' \
--form-string "token=$PUSHOVER_API_TOKEN" \
--form-string "user=$PUSHOVER_USER_KEY" \
--form-string "message=$msg" \
"$NOTIFICATION_URL")
curl_exit="$?"
if [ "$curl_exit" -ne 0 ] || [ "$result" -ne 200 ]; then
echo -e "\aNotify curl failed with $curl_exit and HTTP $result." >&2
return 10
fi
}
# go
export GOPATH="$HOME/go"
export PATH="$PATH:$GOPATH/bin"
export PATH="$PATH:$GOROOT/bin"
gt() {
go test "$@" ./... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
}
gtv() {
go test -v "$@" ./... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
}
gtb() {
go test -bench=. "$@" ./... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
}
gtbv() {
go test -v -bench=. "$@" ./... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
}
gtc() {
local t=$(mktemp -t cover)
go test $COVERFLAGS -coverprofile="$t" "$@" ./... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'' &&
go tool cover -html="$t" &&
unlink "$t"
}
gtch() {
local t=$(mktemp -t cover)
go test $COVERFLAGS -covermode=count -coverprofile="$t" "$@" ./... | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'' &&
go tool cover -html="$t" &&
unlink "$t"
}
alias gl="golangci-lint run"
# Emacs config
edl() {
emacs --eval '(desktop+-load "'"$1"'")'
}
# Starship configs
export STARSHIP_CONFIG="$HOME/.starship.toml"
# ripgrep configs
export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
# Aliases
alias cdr='cd $(git rev-parse --show-toplevel)'
alias gcce="gcc -Wextra -Wpedantic"
alias cs="gh codespace ssh"
alias csc="gh codespace code"
alias old='cd $OLDPWD'
alias edp='rm .emacs-buffers & rm .emacs.desktop'
alias code=code-insiders
alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"
# Prepend brew-installed libraries and includes
export LIBRARY_PATH="$HOMEBREW_PREFIX/lib"
CPATH="$CPATH:$HOMEBREW_PREFIX/include"
export LC_ALL="en_US.UTF-8"
export PATH="$PATH:bin"
SHARED_SHELL_CONFIGS="true"
export SHARED_SHELL_CONFIGS
export GPG_TTY=$(tty)
SSH_AUTH_SOCK=$HOME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh