-
Notifications
You must be signed in to change notification settings - Fork 0
/
shared_shell_configs
152 lines (126 loc) · 4.1 KB
/
shared_shell_configs
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
# 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
if command -v pyenv 1>/dev/null 2>&1; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
export ZSH_PYENV_VIRTUALENV=true
fi
if command -v nodenv 1>/dev/null 2>&1; then
export NODENV_ROOT="$HOME/.nodenv"
export PATH="$NODENV_ROOT/bin:$PATH"
eval "$(nodenv init -)"
fi
if command -v rbenv 1>/dev/null 2>&1; then
export RBENV_ROOT="$HOME/.rbenv"
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
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'
if [ "$(uname)" = "Darwin" ]; then
# GCloud
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
source "$HOMEBREW_PREFIX/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
fi
# 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