-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.symlink
247 lines (196 loc) · 6.98 KB
/
profile.symlink
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
# vim: set ft=sh:
bold="\[$(tput bold)\]"
green="\[$(tput setaf 2)\]"
cyan="\[$(tput setaf 6)\]"
red="\[$(tput setaf 9)\]"
default="\[$(tput sgr0)\]"
## PATH
# Homebrew
# PREFIX=$(brew --prefix)
HOMEBREW_PREFIX=/opt/homebrew
export PATH=/usr/local/sbin:$PATH
export PATH=~/.dotfiles/bin:/usr/local/bin:$HOMEBREW_PREFIX/bin:$PATH
if [[ -d /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin ]]; then
export PATH=$PATH:/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin
fi
if [[ -d /Applications/MacVim.app/Contents/bin ]]; then
export PATH=$PATH:/Applications/MacVim.app/Contents/bin
fi
if [[ -d /usr/local/git-fuzzy/bin ]]; then
export PATH=$PATH:/usr/local/git-fuzzy/bin
fi
# update PATH for the Google Cloud SDK.
if [ -f '/usr/local/google-cloud-sdk/path.bash.inc' ]; then
. '/usr/local/google-cloud-sdk/path.bash.inc';
fi
if which go > /dev/null; then
export PATH=$PATH:/usr/local/opt/go/libexec/bin:$HOME/.go/bin
export GOPATH=$HOME/.go
export GOBIN=$HOME/.go/bin
fi
## VARIABLES
export EDITOR=$HOMEBREW_PREFIX/bin/nvim
export HISTSIZE=-1
export HISTFILESIZE=-1
shopt -s histappend
export VAULT_ADDR="https://vault.prd:8200"
export VAULT_CAPATH="$HOME/.vault_certs/"
export PAGER='less --ignore-case --LONG-PROMPT --RAW-CONTROL-CHARS --chop-long-lines'
## PROMPT
title() {
# echo -ne "\033]0;$@\007"
true
}
# preexec breaks fzf
# source ~/.dotfiles/preexec.bash
preexec () {
title $@
}
precmd () {
title 'bash'
}
fromhex(){
hex=${1#"#"}
r=$(printf '0x%0.2s' "$hex")
g=$(printf '0x%0.2s' ${hex#??})
b=$(printf '0x%0.2s' ${hex#????})
printf '%03d' "$(( (r<75?0:(r-35)/40)*6*6 +
(g<75?0:(g-35)/40)*6 +
(b<75?0:(b-35)/40) + 16 ))"
}
function build_prompt() {
# if [[ $WARP_IS_LOCAL_SHELL_SESSION = '1' ]]; then
# return
# fi
local EXIT="$?"
# Append to history after each command
history -a
PS1="$bold"
if [ $EXIT != 0 ]; then
PS1+="$red$EXIT "
fi
PS1+="$green\u$red@$cyan\h:$red\w$default\$ "
}
export PROMPT_COMMAND=build_prompt
# preexec overrides PROMPT_COMMAND - make sure it's called after.
# preexec_install
# Case-insensitive tab complete
bind 'set completion-ignore-case on'
## COMPLETIONS
if [[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ]]; then
. /opt/homebrew/etc/profile.d/bash_completion.sh
fi
# shell command completion for gcloud.
if [ -f '/usr/local/google-cloud-sdk/completion.bash.inc' ];
then . '/usr/local/google-cloud-sdk/completion.bash.inc';
fi
## ALIASES
alias less="command $PAGER"
# alias dc="docker-compose --file=docker-compose.local-client.yml"
alias dc="docker compose -f docker-compose.yml -f docker-compose.frontend.yml -f docker-compose.m1.yml"
# Use `■` to delimit columns. There is no non-greedy matching in sed, so match 32 non ■
# characters and truncate / add ellipsis.
alias gb="\
git for-each-ref \
--color always \
--sort=committerdate refs/heads/ \
--format='\
%(HEAD) %(color:yellow)%(refname:short)%(color:reset)■\
%(color:red)%(objectname:short)%(color:reset)■\
%(contents:subject)■\
%(authorname)■\
(%(color:green)%(committerdate:relative)%(color:reset))'\
| sed -E 's|■([^■]{32})[^■]*■|■\1…■|g' \
| column -ts'■'
"
alias gs="git status"
alias gd="git diff --color-moved"
alias gp="git push origin HEAD"
alias glog="git log --graph --pretty=format:'%C(red)%h%C(reset) %<(8)%aN - %<(56,trunc)%s %C(yellow)%ar'"
alias gfs='git fuzzy status'
alias gfl='git fuzzy log'
alias cdg='cd $(git rev-parse --show-cdup)'
alias gss="git add . && git commit --no-verify -m '-- PENDING --'"
function gsp() {
last_msg=$(git log -1 --pretty=%B)
if [[ $last_msg == "-- PENDING --" ]]; then
git reset "HEAD^"
else
echo 'Error - last commit not a stash'
fi
}
if which exa > /dev/null; then
alias ls="exa -l"
else
alias ls="ls -lG"
fi
function ff() {
find . -iname "*$@*"
}
alias fixterm='curl https://raw.githubusercontent.com/kovidgoyal/kitty/master/terminfo/x/xterm-kitty | sudo tee /usr/share/terminfo/x/xterm-kitty > /dev/null'
alias fixkitty='kitty +kitten ssh'
alias icat='kitty +kitten icat'
function ssh() {
command ssh $@ -t "tmux attach -t zaius -d || tmux attach -t 0 || bash -l"
}
# https://til.simonwillison.net/til/til/bash_escaping-a-string.md
# https://news.ycombinator.com/item?id=24659282
alias escapequotes='echo !:q'
if which fzf > /dev/null; then
# $(brew --prefix)/opt/fzf/install
# [ -f ~/.fzf.bash ] && source ~/.fzf.bash
source ~/.dotfiles/bash/fzf.bash
fi
# -v ~/.ipython/:/root/.ipython \
alias manage.py='dc run --rm uwsgi-beyond python manage.py'
alias refresh-tags-ignore="cat .gitignore | sed 's/\/$//g' | sed '/^$/d' | sed '/^[\#\|\!]/d' > .ctagsignore"
alias refresh-tags='refresh-tags-ignore; ctags --exclude="@.ctagsignore" --python-kinds=-i --languages=python -R server/; rm .ctagsignore'
vault_secret_id() {
unset TF_VAR_vault_secret_id
secret_id=$(vault write -field secret_id -f auth/approle/role/terraform/secret-id)
if [ -n "$secret_id" ]; then
export TF_VAR_vault_secret_id=$secret_id
echo "Exported TF_VAR_vault_secret_id=$TF_VAR_vault_secret_id"
else
echo "Failed to get secret_id!"
fi
}
export PATH="/usr/local/opt/mysql-client/bin:$PATH"
function lastlog() {
vi -p response-log/$1/`command ls -rt response-log/$1 | tail -n 1`
}
export NOMAD_ADDR=http://stg-nomad.bpdev:4646
## PYENV
# System python bins last - for pylsp / black from vim
export PATH="$PATH:/Users/zaius/Library/Python/3.9/bin"
if [[ -d $HOME/.pyenv/bin ]]; then
export PATH="$HOME/.pyenv/bin:$PATH"
fi
if which pyenv > /dev/null; then
export PYENV_ROOT="$HOME/.pyenv"
eval "$(pyenv init -)"
# Fix compilation of 3.6
# https://stackoverflow.com/questions/66482346/problems-installing-python-3-6-with-pyenv-on-mac-os-big-sur
export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/bzip2/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/bzip2/include"
fi
## NVM / Node
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
# Keep quiet on mac when using bash
# https://support.apple.com/en-us/HT208050
export BASH_SILENCE_DEPRECATION_WARNING=1
if test -n "$KITTY_INSTALLATION_DIR"; then
export KITTY_SHELL_INTEGRATION="enabled"
source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
fi
# Use local chromium for puppeteer so we can avoid rosetta
if which chromium > /dev/null; then
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PUPPETEER_EXECUTABLE_PATH=`which chromium`
fi
alias nomad-shell='NOMAD_ADDR=http://prd-nomad.prd:4646 nomad alloc exec $(python /Users/zaius/code/beyond/server/shell.py -e prd -s zaius -q) tmux att -t app-shell'
export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"
# Added by OrbStack: command-line tools and integration
source ~/.orbstack/shell/init.bash 2>/dev/null || :