forked from w3cj/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bash_profile
More file actions
278 lines (253 loc) · 9.3 KB
/
Copy path.bash_profile
File metadata and controls
278 lines (253 loc) · 9.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
# Notes
# list=(a b c); for t in ${list[@]}; do pip uninstall $t -y; done
# add kernel: ipython kernel install --name "local-venv" --user
# ------------------------------------ Path ------------------------------------
export PATH="/usr/local/bin:$PATH"
export PATH="/home/$USER/.local/bin/:$PATH"
export PATH="/usr/local/texlive/2025/bin/x86_64-linux:$PATH"
export PYENV_ROOT="$HOME/.pyenv"
export LUA_CPATH=";;"
export MANPATH=/usr/local/texlive/2025/texmf-dist/doc/man:$MANPATH
export INFOPATH=/usr/local/texlive/2025/texmf-dist/doc/info:$INFOPATH
# ---------------------------------- Secrets ----------------------------------
for key_file in ~/.config/*key; do
[ -f "$key_file" ] && source "$key_file"
done
# ---------------------------------- Settings ----------------------------------
shopt -s checkwinsize # check window size
set -o vi # vi mode
set show-mode-in-prompt on
set syntax on
set bell-style visible
set filec
nvim_appimage=$(find ${HOME} -maxdepth 1 -name nvim*appimage 2>/dev/null)
if [ -n "$nvim_appimage" ]; then
alias v="$nvim_appimage"
alias nvim="$nvim_appimage"
export EDITOR="$nvim_appimage"
else
alias v='nvim'
export EDITOR='nvim'
fi
shopt -s histappend
HISTCONTROL=ignoreboth
export HISTSIZE=100000
export HISTFILESIZE=100000
export BASH_SILENCE_DEPRECATION_WARNING=1
## make tab cycle through commands after listing
bind 'TAB:menu-complete'
bind "set show-all-if-unmodified on"
bind "set completion-ignore-case on"
bind "set menu-complete-display-prefix on"
bind '"\C-h": backward-kill-word'
# enable bash completion in interactive shells
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
complete -f ss # autocomplete for custom commands
# ----------------------------------- Prompt -----------------------------------
emojis=("🌀" "💀" "👽" "👾" "💜" "🦄" "🐙" "🌸" "🌄" "🎃" "🎆" "🔮" "🧿")
EMOJI=${emojis[$RANDOM % ${#emojis[@]} ]}
H=$(hostname -s)
if [[ $H == "virga"* ]]; then
HOST_PART="vi${H:7}"
else
HOST_PART=${H:0:3}
fi
export PS1="\[\e[0m\]$EMOJI \[\e[36m\]$HOST_PART\[\e[0m\] \[\e[38;5;140m\]\W\[\e[0m\] > "
export PS2=">"
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
set_title() { printf '\033]0;%s\007' "$*"; }
user_title() { echo -ne "\033]0;$1\007"; }
# keep existing PROMPT_COMMAND if present
# PROMPT_COMMAND='set_title "${PWD/#$HOME/~}"'"${PROMPT_COMMAND:+; $PROMPT_COMMAND}"
# ---------------------------------- Aliases ----------------------------------
alias o="open ."
alias l="ls"
alias ss='subl -a '
alias sm='/usr/bin/smerge'
alias python='python3'
alias jupysync='jupytext --to py:light notebooks/*ipynb; mv notebooks/*py notebooks/py_scripts; black notebooks/py_scripts'
alias profilev='nvim ~/.bash_profile'
alias loadprofile='source ~/.bash_profile'
alias bck="echo ' > /dev/null 2>&1 &' | pbcopy"
alias pbcopy='xclip -selection c -rmlastnl'
alias vdo="v ~/wrk/ucsf-notes.txt"
alias vj="v ~/Documents/journal.md"
alias vp="v ~/Documents/poetry.md"
alias tmux="TERM=screen-256color-bce tmux"
alias tm='tmux has-session -t 0 2>/dev/null && TERM=screen-256color-bce tmux attach -t 0 || TERM=screen-256color-bce tmux'
alias spellcheckdir="cspell -c cspell.json ./**/*{py,md,yaml}"
alias pcc="pre-commit run --all-files"
alias mdlcheck="goruby; mdl -c .markdownlint.yaml ."
alias dlx="yt-dlp -x -t mp3 "
## Python
alias pip='python -m pip'
alias ipython='python -m IPython'
alias pytest='python -m pytest'
alias ptest="pytest --no-teardown --pdb --sw"
## Git
alias ga='git add'
alias gaa='git add .'
alias gc='git commit'
alias gcm='git commit -m'
alias gp='git pull'
alias grom='git remote rename origin me'
gdb() { # Function to delete local branches not present on the 'me' remote
git fetch me --prune
for branch in $(git branch | grep -v '^\*' | grep -v 'main'); do
if ! git show-ref --verify --quiet refs/remotes/me/"$branch"; then
if [ "$1" == "do" ]; then # if argument is 'do', delete the branch
git branch -D "$branch" # Use -D to force delete unmerged
else
echo "No remote branch me/'$branch'"
fi
fi
done
}
## Environments
alias off="conda deactivate"
alias gospy="cd '${HOME}/wrk/spyglass'; conda activate spy"
alias goruby="source ${HOME}/.rvm/scripts/rvm # ruby version manager; rvm --default use 2.7 >/dev/null"
# --------------------------------- Functions ---------------------------------
alias funcs="declare -F | grep -vE \"^declare -f _|^declare -f nvm\""
piphas() { pip list | grep "$1"; }
cact() { conda activate "$1"; }
ipy() { ${HOME}/miniconda3/envs/"$1"/bin/python -m IPython --no-autoindent; }
spellcheck() { cspell check "$1" --color | less -r; }
jupythis() { jupytext --to py notebooks/*"$1"*ipynb ; mv notebooks/*py notebooks/py_scripts; }
loadenv() { export $(grep -v '^#' "${1:-.env}" | xargs); }
scpdown() { scp -i $HOME/.ssh/ucsf -P ${UCSF_SSH_PORT} cbroz@virga-05.cin.ucsf.edu:~/wrk/spyglass/"$1" ~/wrk/spyglass/"$1"; }
scpup() { scp -i $HOME/.ssh/ucsf -P ${UCSF_SSH_PORT} ~/wrk/spyglass/"$1" cbroz@virga-05.cin.ucsf.edu:~/wrk/spyglass/"$1"; }
killbyname() { killall -s 9 "$1"; }
lt_git_ignore() {
ignored=$(git ls-files --others --ignored --exclude-standard)
lt | grep -vFf <(echo "$ignored")
}
# ------------------------ Docker ------------------------
if command -v docker &>/dev/null; then
## Docker
alias dockerprune="\
docker container prune -f;\
docker image prune -af;\
docker builder prune -f;\
docker volume prune -f;\
docker network prune -f;\
docker system df"
alias dockermirr="dockerrm mirr; \
docker volume prune -f; \
docker run --cap-add=sys_nice \
--name mirr -p 3306:3306 -e MYSQL_ROOT_PASSWORD=tutorial mysql:latest"
alias dockerps="docker ps -a --format \"{{.ID}} {{.Names}}\""
dockerrm() {
for container_id in "$@"; do
docker stop "$container_id" >/dev/null 2>&1
docker rm "$container_id" >/dev/null 2>&1
echo "Container $container_id stopped and removed"
done
}
alias dockerrmtest="dockerrm spyglass-pytest"
fi
# ----------------------------------- Conda -----------------------------------
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/$USER/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/$USER/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/$USER/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/$USER/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
if command -v conda &>/dev/null; then
conda config --set auto_activate false
fi
# ------------------------------------ fzf ------------------------------------
# CTRL-R script to insert command from history into the command line/region
if command -v fzf &>/dev/null; then
# if command -v ag &>/dev/null; then
# export FZF_DEFAULT_COMMAND='ag -g "" --ignore "trainset"'
# else
# export FZF_DEFAULT_COMMAND='--ignore "trainset"'
# fi
__fzf_history ()
{
builtin history -a;
builtin history -c;
builtin history -r;
builtin typeset \
READLINE_LINE_NEW="$(
HISTTIMEFORMAT= builtin history |
command fzf +s --tac +m -n2..,.. --tiebreak=index --toggle-sort=ctrl-r |
command sed '
/^ *[0-9]/ {
s/ *\([0-9]*\) .*/!\1/;
b end;
};
d;
: end
'
)";
if
[[ -n $READLINE_LINE_NEW ]]
then
builtin bind '"\er": redraw-current-line'
builtin bind '"\e^": magic-space'
READLINE_LINE=${READLINE_LINE:+${READLINE_LINE:0:READLINE_POINT}}${READLINE_LINE_NEW}${READLINE_LINE:+${READLINE_LINE:READLINE_POINT}}
READLINE_POINT=$(( READLINE_POINT + ${#READLINE_LINE_NEW} ))
else
builtin bind '"\er":'
builtin bind '"\e^":'
fi
}
builtin set -o histexpand;
builtin bind -x '"\C-x1": __fzf_history';
builtin bind '"\C-r": "\C-x1\e^\er"'
alias ff='fzf'
alias vf='v $(ff)'
fi
# ------------------------------------ NVM ------------------------------------
if command -v nvm &>/dev/null; then
source ~/.nvm/nvm.sh
export NVM_DIR="$HOME/.nvm"
fi
# ----------------------------------- Tools -----------------------------------
# zoxide, thefuck, fd, sd, exa, ncdu
if command -v zoxide &>/dev/null; then
eval "$(zoxide init bash)"
alias g='z'
else
alias g='echo "zoxide not installed"; cd'
fi
if command -v thefuck &>/dev/null; then
eval "$(thefuck --alias)" || true
alias fuck='thefuck'
else
alias fuck='echo "no fucks to give"'
fi
if command -v eza &>/dev/null; then
alias ll='eza -l --icons --git -a'
alias lt='eza --tree --level=2 --long --icons --git'
alias lg='eza --tree --level=1 --long --icons --git --git-ignore'
alias lgg='eza --tree --level=2 --long --icons --git --git-ignore'
else
alias ll='ls -al --color=auto'
alias lt='tree -L 2'
alias lg='lt_git_ignore'
fi
if command -v ncdu &>/dev/null; then
alias duu='ncdu --color dark'
fi
if command -v batcat &>/dev/null; then
alias bat='batcat'
else
alias bat='echo "batcat not installed"; cat'
fi
GPG_TTY=`tty`
export GPG_TTY
# . "$HOME/.cargo/env"