-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdot_zshrc.tmpl
232 lines (184 loc) · 7.05 KB
/
dot_zshrc.tmpl
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
{{ if eq .chezmoi.os "linux" }}
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Source Prezto
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Init zplug
if [[ ! -d ~/.zplug ]];then
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
fi
source ~/.zplug/init.zsh
# Select zplug plugins
zplug "agkozak/zsh-z"
zplug "junegunn/fzf"
zplug "yuhonas/zsh-aliases-lsd"
zplug "romkatv/powerlevel10k", as:theme, depth:1
# Make sure that plugins are installed
if ! zplug check --verbose; then
printf "Installing missing zplug plugins...\n"
zplug install
fi
# Load Zplug plugins
zplug load
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
{{else if eq .chezmoi.os "darwin" -}}
export PATH="$PATH:$HOME/bin"
export PATH="$PATH:$HOME/.fzf/bin"
export PATH="/opt/homebrew/bin:$PATH"
if [ -z "$TMUX" ]
then
export TMUX_CONF="$HOME/.tmux.conf"
username=$(basename $HOME)
if command -v tmux >/dev/null 2>&1; then
exec env TMUX_TMPDIR=/tmp tmux -u2 -f "$TMUX_CONF" new-session -As "$username" -c "$HOME"
else
echo "tmux not found. Please install it via Homebrew or another package manager."
fi
fi
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Source Prezto
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Init zplug
if [[ ! -d ~/.zplug ]];then
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
fi
source ~/.zplug/init.zsh
# Select zplug plugins
zplug "agkozak/zsh-z"
zplug "junegunn/fzf"
zplug "yuhonas/zsh-aliases-lsd"
zplug "romkatv/powerlevel10k", as:theme, depth:1
# Make sure that plugins are installed
if ! zplug check --verbose; then
printf "Installing missing zplug plugins...\n"
zplug install
fi
# Load Zplug plugins
zplug load
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
declare -a NODE_GLOBALS=(`find ~/.nvm/versions/node -maxdepth 3 -type l -wholename '*/bin/*' | xargs -n1 basename | sort | uniq`)
NODE_GLOBALS+=("node")
NODE_GLOBALS+=("nvm")
load_nvm () {
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 (optional)
nvm use 20 # This tells nvm to use Node.js version 18
}
for cmd in "${NODE_GLOBALS[@]}"; do
eval "${cmd}(){ unset -f ${NODE_GLOBALS}; load_nvm; ${cmd} \$@ }"
done
export PATH="/Users/nathanbraun/.nvm/versions/node/v18.19.1/bin/node:$PATH"
# set editor
export EDITOR=/opt/homebrew/bin/nvim
export VISUAL=/opt/homebrew/bin/nvim
# tmux aliases
alias t="tmux"
alias ta="t a -t"
alias tls="t ls"
alias tn="t new -t"
alias tid='tmux display-message -p "#S"'
function tk () {
tmux kill-session -t $(tmux display-message -p '#S')
docker kill $(docker ps -q) > /dev/null 2>&1
}
alias muxstart='tmuxinator start'
alias zc="cd /Users/nathanbraun/code/github.com/nathanbraun"
alias upip="pip install --upgrade pip"
export APY_ANKI_PATH=/Users/nathanbraun/anki/anki-2.1.40
export PATH="$PATH:$HOME/bin"
export PATH="$PATH:$HOME/.local/bin"
export PATH="$PATH:/Applications/Racket v8.10/bin"
fpath=($HOME/.local/zsh-functions $fpath)
export PATH="/opt/homebrew/bin:$PATH"
# function tn() (
# if [ -n "$1" ]
# then
# tmux switch -t $1
# else
# echo "no session name"
# fi
# )
export PATH="/opt/homebrew/sbin:$PATH"
export PATH="/usr/local/texlive/2021/bin/universal-darwin:$PATH"
export PATH=/usr/local/smlnj/bin:"$PATH"
tmux_jump() {
# starting in ~/code...
BASE="$HOME/code/github.com"
# ... look for directories exactly two levels deep (`~/code/owner/project`)
# and match them with fzf. In this case we break ties by favoring matches
# on the project name instead of the owner name (implementaion means
# favoring matches closer to the end of the string.) This is simplified a
# little bit with the `--select-1 --query="$1"` line: if there's only one
# match for the argument passed in as the first argument to this function,
# we select immediately instead of asking for an interactive selection.
SELECTED=$(find "$BASE" -mindepth 2 -maxdepth 2 -type d | sed "s|$BASE/||g" | fzf --tiebreak=end --select-1 --query="$1")
# fzf will exit with a non-zero code if you ctrl-c or ctrl-g out of
# it. We use this as a signal that we don't want to jump after all.
if [[ "$?" != 0 ]]; then echo "cancelling!"; return 1; fi
# call tmux-session on the *full* path to the matched project!
tmux-session "$BASE/$SELECTED"
}
# and alias this so I can just do `t bytes.zone` instead of having to type
# tmux_jump every time.
alias tj=tmux_jump
alias ts=tmux-session
export PATH="/Applications/kitty.app/Contents/MacOS:$PATH"
alias sicp="rlwrap --always-readline -S '> ' -- racket -e '(require sicp)' -i"
[ -f "/Users/nathanbraun/.ghcup/env" ] && . "/Users/nathanbraun/.ghcup/env" # ghcup-env
{{end -}}
export PYTHONBREAKPOINT="IPython.embed"
################################################################################
# put in vi mode:
################################################################################
bindkey -v
# add kj and jk to insert mode
bindkey -M viins 'kj' vi-cmd-mode
bindkey -M viins 'jk' vi-cmd-mode
bindkey '^p' history-beginning-search-backward
bindkey '^n' history-beginning-search-forward
# Change cursor shape for different vi modes.
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
}
if [ -f ~/.zshrc_local ]; then
source ~/.zshrc_local
fi
alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# aliases
# alias pomo='noti pomodoro --simple'
# alias dash='noti pomodoro --simple 5'
alias gg="lazygit"
alias chd='cd "$(chezmoi source-path)"'
alias cha="chezmoi apply"
alias ssh='TERM=xterm-256color \ssh'
setopt INC_APPEND_HISTORY
export NOTES_DIR="$HOME/notes"
export ZK_NOTEBOOK_DIR="$NOTES_DIR/.zk"
# bun completions
[ -s "/Users/nathanbraun/.bun/_bun" ] && source "/Users/nathanbraun/.bun/_bun"
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"