-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
291 lines (236 loc) · 11.2 KB
/
.zshrc
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
#
# __
# /__\
# /(__)\
# (__)(__)
#
# github.com/adlrwbr
# Made with ⌛&♥ by Adler Weber
#
# ============================================================================
# ⚙ Package managers ⚙
# ============================================================================
# snap (linux package manager) configuration
export PATH="/var/lib/snapd/snap/bin:$PATH"
# cargo (rust build / package manager) configuartion
source "$HOME/.cargo/env"
# conda (python virtual env / package manager) configuration
source /home/adler/.config/op/plugins.sh
[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh
# opam (ocaml package manager) configuration
[[ ! -r /home/adler/.opam/opam-init/init.zsh ]] || source /home/adler/.opam/opam-init/init.zsh > /dev/null 2> /dev/null
# pnpm (performant node package manager) configuration
export PNPM_HOME="/home/adler/.local/share/pnpm"
export PATH="$PNPM_HOME:$PATH"
# enable miniconda3
[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh
# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE='/usr/bin/micromamba';
export MAMBA_ROOT_PREFIX='/home/adler/micromamba';
__mamba_setup="$("$MAMBA_EXE" shell hook --shell zsh --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
alias micromamba="$MAMBA_EXE" # Fallback on help from mamba activate
fi
unset __mamba_setup
# <<< mamba initialize <<<
# JINA_CLI_BEGIN
## autocomplete
if [[ ! -o interactive ]]; then
return
fi
compctl -K _jina jina
_jina() {
local words completions
read -cA words
if [ "${#words}" -eq 2 ]; then
completions="$(jina commands)"
else
completions="$(jina completions ${words[2,-2]})"
fi
reply=(${(ps:
:)completions})
}
# session-wise fix
ulimit -n 4096
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
# JINA_CLI_END
#compdef k3s
_cli_zsh_autocomplete() {
local -a opts
local cur
cur=${words[-1]}
if [[ "$cur" == "-"* ]]; then
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
else
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
fi
if [[ "${opts[1]}" != "" ]]; then
_describe 'values' opts
else
_files
fi
return
}
compdef _cli_zsh_autocomplete k3s
eval "$(zoxide init zsh)"
# to run my 4775 scDeepSort (which requires tensorflow)
# after running these try sudo ldconfig
# export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/adler/.conda/envs/4775-scDeepSort/lib/"
# export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/adler/.conda/pkgs/cudatoolkit-11.8.0-h6a678d5_0/lib/"
# export USE_OFFICIAL_TFDLPACK=1
# test with
# python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
# ============================================================================
# ⚙ Oh-my-zsh and themes ⚙
# ============================================================================
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="juanghurtado" # I like this
ZSH_THEME="dpoggi" # I like this
# ZSH_THEME="steeef" # I don't like this because the git icons wait for `git status`
# ZSH_THEME="half-life" # same as above
# ZSH_THEME="robbyrussell" # I don't like this because it shortens the directory name (no full CWD)
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Update oh-my-zsh automatically without asking
zstyle ':omz:update' mode auto
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
# install zsh-syntax-highlighting
OMZ_SYNTAX_HIGHLIGHTING=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
[ -d $OMZ_SYNTAX_HIGHLIGHTING ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $OMZ_SYNTAX_HIGHLIGHTING
# install zsh-history-substring-search
OMZ_HISTORY_SEARCH=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
[ -d $OMZ_HISTORY_SEARCH ] || git clone https://github.com/zsh-users/zsh-history-substring-search $OMZ_HISTORY_SEARCH
# install zsh-autosuggestions
OMZ_AUTOSUGGESTIONS=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
[ -d $OMZ_AUTOSUGGESTIONS ] || git clone https://github.com/zsh-users/zsh-autosuggestions $OMZ_AUTOSUGGESTIONS
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
# lazy load NVM
zstyle ':omz:plugins:nvm' lazy yes
# Oh-my-zsh includes nvm, so we don't need these lines:
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
plugins=(git zsh-syntax-highlighting zsh-history-substring-search zsh-autosuggestions nvm poetry)
source $ZSH/oh-my-zsh.sh
# ============================================================================
# ⚙ fzf ⚙
# ============================================================================
if command -v fzf &> /dev/null; then
export FZF_ALT_C_COMMAND='fd --type=directory --hidden --follow --exclude={.git,.bare,.idea,.gradle,.vscode,__pycache__,.nix,.nix-defexpr,.steam,.rustup,.m2,.vmware,vendor,.conda,pkg,site-packages,.sass-cache,.cargo,.fingerprint,deps,go,Pods,.mozilla,.npm,pnpm,.local,.cache,node_modules,build,dist,tmp}'
source /usr/share/fzf/completion.zsh
# ctrl-T for files under the current dir
# ctrl-r for history
# alt-c to cd into dirs under the current dir
source /usr/share/fzf/key-bindings.zsh
else
echo "Warning: fzf not found."
fi
# ============================================================================
# ⚙ Options and misc config ⚙
# ============================================================================
setopt correct # Auto correct mistakes
setopt extendedglob # Extended globbing. Allows using regular expressions with *
setopt nocaseglob # Case insensitive globbing
setopt rcexpandparam # Array expension with parameters
setopt nocheckjobs # Don't warn about running processes when exiting
setopt numericglobsort # Sort filenames numerically when it makes sense
setopt nobeep # No beep
setopt appendhistory # Immediately append history instead of overwriting
setopt hist_ignore_dups # ignore duplicated commands history list
setopt autocd # if only directory path is entered, cd there.
setopt inc_append_history # save commands are added to the history immediately, otherwise only when shell exits.
setopt hist_ignore_space # Don't save commands that start with space
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' # Case insensitive tab completion
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Colored completion (different colors for dirs/files/etc)
zstyle ':completion:*' rehash true # automatically find new executables in path
# Speed up completions
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
# bind UP and DOWN arrow keys to history substring search
zmodload zsh/terminfo
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# Use vi mode
# set -o vi
# Set EDITOR depending on if session is local/remote session
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='nvim'
fi
# open a file in obsidian using the URL schema support
# Usage `obs file.md`
function obs() {
local file_url="obsidian://$(realpath "$1")"
echo $file_url
# xdg-open "$file_url" >/dev/null 2>&1 & disown
xdg-open "$file_url" >/dev/null & disown
}
# Git worktree clone
# Sets up a clean worktree directory with all bare files hidden in .bare
function gwtc() {
if [ "$#" -ne 2 ]; then
echo "Git worktree clone: clone a repo, set up a worktree dir, check out main"
echo "Usage: gwtc <repo URL> <directory name>"
return 1
fi
URL="$1"
DIRNAME="$2"
mkdir -p $DIRNAME
git clone --bare "$URL" "$DIRNAME/.bare"
echo "gitdir: ./.bare" > "$DIRNAME/.git"
cd $DIRNAME
git worktree add main
cd main
git push --set-upstream origin HEAD
}
# 1Password CLI
source ~/.config/op/plugins.sh
# custom aliases: view all with `alias`
alias sz="source ~/.zshrc"
alias oldvim="NVIM_APPNAME=nvim-vimscript nvim" # my previous nvim config
alias nvchad="NVIM_APPNAME=nvchad nvim"
alias s="kitty +kitten ssh" # automatically copy terminfo files to server: see https://sw.kovidgoyal.net/kitty/faq/#i-get-errors-about-the-terminal-being-unknown-or-opening-the-terminal-failing-or-functional-keys-like-arrow-keys-don-t-work
alias clear="clear; echo Tsk tsk...use ctrl-l!"
alias du="dust"
alias psql=" psql" # don't append psql commands (which contain sensitive info) to zsh_history
alias gs="git status"
# custom path/env vars
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.local/bin/armv6:$PATH"
export TERMINAL="kitty" # rofi uses this var to launch scripts / ssh
export MYACE_AWS_PROFILE="myace"
export AWS_PROFILE="carbonweb"
export AWS_PROFILE="friday"
export AWS_PROFILE="herme"
export AWS_PROFILE="roam"