-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc.tmpl
216 lines (173 loc) · 6.66 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
# vim: ft=zsh:
#
# XDG spec reference: https://wiki.archlinux.org/title/XDG_Base_Directory
# 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
{{ if eq .osid "darwin" }}
# required for openjdk java to load before system java
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
{{ end }}
{{ if lookPath "yarn" }}
export PATH="$(yarn global bin):$PATH"
{{ end }}
export PATH="$HOME/.local/share/bin:$HOME/.local/bin:$HOME/.local/bin/update/bin:$HOME/bin:/usr/local/bin:$HOME/.local/share/git-fuzzy/bin:$PATH"
{{ if eq .osid "darwin" }}
# Add Visual Studio Code (code)
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
{{ end }}
{{ if eq .osid "darwin" }}
############################################################
# 1password github integration
[ -f ~/.config/op/plugins.sh ] && source ~/.config/op/plugins.sh
# enable biometrics for 1password CLI (op)
if type op &>/dev/null
then
export OP_BIOMETRIC_UNLOCK_ENABLED=true
fi
############################################################
{{ else if eq .osid "linux" }}
############################################################
# enable quiet & lazy to silence ssh-agent from interrupting p10k prompt
zstyle :omz:plugins:ssh-agent quiet yes
zstyle :omz:plugins:ssh-agent lazy yes
############################################################
{{ end }}
{{ if lookPath "zoxide" }}
eval "$(zoxide init zsh)"
{{ end }}
{{ if lookPath "oh-my-posh" }}
if [ "$TERM_PROGRAM" != "Apple_Terminal" ]; then
# eval "$(oh-my-posh init zsh --config $(brew --prefix oh-my-posh)/themes/1_shell.omp.json)"
eval "$(oh-my-posh init zsh --config $XDG_CONFIG_HOME/oh-my-posh/themes/mauvehed.omp.json)"
fi
{{ end }}
{{ if .personal }}
export OPENAI_API_KEY={{ onepasswordRead "op://Personal/OpenAI API Key/api key" }}
export DIGITALOCEAN_ACCESS_TOKEN={{ onepasswordRead "op://Personal/DigitalOcean Personal Access Token/token" }}
# history setup
HISTFILE=$HOME/.zhistory
SAVEHIST=1000
HISTSIZE=999
setopt share_history
setopt hist_expire_dups_first
setopt hist_ignore_dups
setopt hist_verify
# completion using arrow keys (based on history)
#bindkey '^[[A' history-search-backward
#bindkey '^[[B' history-search-forward
{{ else }}
# Don't track shell history
unset HISTFILE
{{ end }}
# Recommended by pyenv oh-my-zsh plugin
# if type pyenv &>/dev/null
# then
# export PYENV_ROOT="$HOME/.pyenv"
# export PATH="$PYENV_ROOT/bin:$PATH"
# command -v pyenv >/dev/null && eval "$(pyenv init --path)"
# fi
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
#ZSH_THEME="powerlevel10k/powerlevel10k"
# Set ohmyzsh plugins use
plugins=(
{{ if eq .osid "darwin" }}macos{{ end }}
{{ if eq .chezmoi.os "linux" }}ssh-agent{{ end }}
{{ if .personal }}1password{{ end }}
aliases
tmux
git
python
docker
gitignore
git-auto-fetch
gh
vscode
aws
asdf
direnv
virtualenv
zsh-syntax-highlighting
)
# call and load oh-my-zsh
[ -f $ZSH/oh-my-zsh.sh ] && source $ZSH/oh-my-zsh.sh
# set aliases
[ -f ~/.aliases ] && source ~/.aliases
# run uptime check to warn if over 60 days
[ -f ~/.local/bin/check_uptime.sh ] && bash ~/.local/bin/check_uptime.sh
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
#[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# execute fzf fuzzy stuff
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_OPTS="--color=fg:${fg},bg:${bg},hl:${purple},fg+:${fg},bg+:${bg_highlight},hl+:${purple},info:${blue},prompt:${cyan},pointer:${cyan},marker:${cyan},spinner:${cyan},header:${cyan}"
# -- Use fd instead of fzf --
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"
# Use fd (https://github.com/sharkdp/fd) for listing path candidates.
# - The first argument to the function ($1) is the base path to start traversal
# - See the source code (completion.{bash,zsh}) for the details.
_fzf_compgen_path() {
fd --hidden --exclude .git . "$1"
}
# Use fd to generate the list for directory completion
_fzf_compgen_dir() {
fd --type=d --hidden --exclude .git . "$1"
}
source ~/.local/bin/fzf-git.sh
# Advanced customization of fzf options via _fzf_comprun function
# - The first argument to the function is the name of the command.
# - You should make sure to pass the rest of the arguments to fzf.
_fzf_comprun() {
local command=$1
shift
case "$command" in
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo \${}'" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
*) fzf --preview "$show_file_or_dir_preview" "$@" ;;
esac
}
# execute asdf & direnv
[ -f $HOMEBREW_PREFIX/opt/asdf/libexec/asdf.sh ] && . $HOMEBREW_PREFIX/opt/asdf/libexec/asdf.sh
[ -f $XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc ] && . $XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc
# dracula theme for eza/exa
[ -f ~/.local/share/zsh/site-functions/exa_colors.zshrc ] && . ~/.local/share/zsh/site-functions/exa_colors.zshrc
if type brew &>/dev/null
then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
# initialise completions with ZSH's compinit
autoload -Uz compinit && compinit
fi
{{ if eq .osid "darwin" }}
[ -f $XDG_CONFIG_HOME/iterm2/iterm2_shell_integration.zsh ] && . $XDG_CONFIG_HOME/iterm2/iterm2_shell_integration.zsh
{{ end }}
autoload -Uz add-zsh-hook
autoload -Uz chpwd_functions
chpwd_functions+=ensure_envrc
ensure_envrc() {
if [ -d ".git" ]; then
if [ ! -f ".envrc" ]; then
echo "use asdf" > .envrc
direnv allow
echo "Created and allowed .envrc with 'use asdf' in $(pwd)"
elif ! grep -q "use asdf" .envrc; then
echo "use asdf" >> .envrc
direnv allow
echo "Updated .envrc with 'use asdf' in $(pwd)"
fi
fi
}
try_mosh_host () {
local host="$1"
/opt/homebrew/bin/mosh --server /home/linuxbrew/.linuxbrew/bin/mosh-server "$host" 2> /dev/null || /opt/homebrew/bin/mosh --server /home/linuxbrew/.linuxbrew/bin/mosh-server --server=/usr/bin/mosh-server "$host" 2> /dev/null || /opt/homebrew/bin/mosh --server /home/linuxbrew/.linuxbrew/bin/mosh-server --server=/usr/local/bin/mosh-server "$host" 2> /dev/null || /usr/bin/ssh "$host"
}
alias mosh=try_mosh_host
# set bold, white fg, red bg
export GREP_COLORS='mt=1;37;41'
# set bat theme
export BAT_THEME=Dracula