-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc.tmpl
256 lines (218 loc) · 7.57 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
############################################################################
### Oh My Zsh settings & plugins
############################################################################
# Setup $PATH.
export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
# Path to oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the oh-my-zsh theme to load
# The theme only loads while starship prompt is not installed and activated
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="bira"
# Uncomment the following line if pasting URLs and other text is messed up.
DISABLE_MAGIC_FUNCTIONS="true"
# Ignore commands that start with spaces and duplicates.
export HISTCONTROL=ignoreboth
# Don't add certain commands to the history file.
export HISTIGNORE="&:[bf]g:c:clear:clr:history:exit:q:pwd:* --help"
# eza settings
zstyle ':omz:plugins:eza' 'dirs-first' yes
zstyle ':omz:plugins:eza' 'icons' yes
# OS specific plugins
# brew needs to be loaded first. Otherwise the brew-installed packages aren't available on the PATH.
{{- if eq .osid "darwin" }}
plugins+=(
brew
docker
docker-compose
)
# lazydocker alias
alias lzd='lazydocker'
# Disable Homebrew hints
export HOMEBREW_NO_ENV_HINTS=1
{{ else if eq .osid "linux-ubuntu" "linux-debian" }}
plugins+=(
brew
ubuntu
)
# Disable Homebrew hints
export HOMEBREW_NO_ENV_HINTS=1
{{- end }}
# Host specific plugins
{{- if eq .chezmoi.hostname "nina-desktop" "RTY-6495672069" "docker" }}
plugins+=(
docker
docker-compose
)
# lazydocker alias
alias lzd='lazydocker'
{{- end }}
# General plugins that should be loaded on every host
plugins+=(
chezmoi
common-aliases
direnv
eza
fzf
git
history
nvm
rsync
ssh
systemadmin
ubuntu
zsh-autosuggestions
zsh-syntax-highlighting
zoxide
)
# Load oh-my-zsh
source $ZSH/oh-my-zsh.sh
############################################################################
### Aliases
############################################################################
# Reload zsh (e.g. after editing .zshrc or editing plugins)
alias src='exec zsh'
# Edit .zshrc in the chezmoi source directory
alias zshrc='chezmoi edit ${ZDOTDIR:-$HOME}/.zshrc'
# Replace cat with bat
alias cat='bat'
# More eza aliases
alias l='ll' # make alias l the same as ll (eza -gl)
alias lt='ls --tree' # tree alias (ls is already aliased to eza)
alias lat='ls -a --tree' # tree alias including hidden folder/files
# Pipe output to fzf with 'command F' instead of 'command | fzf'
alias -g F="| fzf"
# Replace grep with ugrep
alias grep='ug'
alias egrep='ug -E'
alias fgrep='ug -F'
alias xzgrep='ug -z'
alias xzegrep='ug -zE'
alias xzfgrep='ug -zF'
# lazigit alias
alias lg='lazygit'
# Replace cd with z (zoxide)
alias cd="z"
# Zellij aliases
alias zls='zellij list-sessions'
alias zd='zellij delete-session'
alias zda='zellij delete-all-sessions'
alias zk='zellij kill-session'
alias zka='zellij kill-all-sessions'
alias zj='zellij' # creates a new session regardless of existing ones
alias zla='zellij --layout'
############################################################################
### Tools initializations & settings
############################################################################
# Set preferred editor
# Use vscode when inside vscode terminal, otherwise use nvim
if [[ $TERM_PROGRAM == 'vscode' ]]; then
export EDITOR='code --wait'
else
export EDITOR='nvim'
fi
# Initialize Starship prompt
eval "$(starship init zsh)"
# Initialize atuin
eval "$(atuin init zsh)"
# Set fzf colors (Catppuccin Mocha)
export FZF_DEFAULT_OPTS=" \
--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8 \
--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc \
--color=marker:#b4befe,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8 \
--color=selected-bg:#45475a \
--multi"
# Use bat & eza previews in fzf
show_file_or_dir_preview="if [ -d {} ]; then eza --tree --color=always {} | head -200; else bat -n --color=always --line-range :500 {}; fi"
export FZF_CTRL_T_OPTS="--preview '$show_file_or_dir_preview'"
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
# 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' "$@" ;;
*) fzf --preview "$show_file_or_dir_preview" "$@" ;;
esac
}
# Function for yazi to start it with just a 'y' and cd into the directory, you're currently in, when exiting yazi
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
# Zellij function to either attach/resurrect a session or create a new one, if none exists
# No session: create new session
# One session (alive or exited): attach / resurrect session
# Two or more sessions (alive or exited): select session with fzf
function za() {
local ZJ_SESSIONS=$(zellij list-sessions -n -s)
local NO_SESSIONS=$(echo "${ZJ_SESSIONS}" | wc -w)
if [ "${NO_SESSIONS}" -eq 1 ]; then
zellij attach "$ZJ_SESSIONS"
elif [ "${NO_SESSIONS}" -ge 2 ]; then
zellij attach "$(echo "${ZJ_SESSIONS}" | fzf)"
else
zellij
fi
}
# Controls Zellij autostart. Set to "true" in host specifc settings to enable.
export ZELLIJ_AUTO_START="false"
############################################################################
### Host specific settings, variables, aliases, ...
############################################################################
{{- if eq .chezmoi.hostname "nina-desktop" "MacBook-Air-von-Nina" "RTY-6495672069" }}
# autostart zellij
export ZELLIJ_AUTO_START="true"
{{- end }}
{{- if eq .chezmoi.hostname "nina-desktop" }}
# Init ssh-agent so vscode can forward the keys to a dev container
if [ -z "$SSH_AUTH_SOCK" ]; then
# Check for a currently running instance of the agent
RUNNING_AGENT="$(ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]')"
if [ "$RUNNING_AGENT" = "0" ]; then
# Launch a new instance of the agent
ssh-agent -s &>$HOME/.ssh/ssh-agent
fi
eval $(cat $HOME/.ssh/ssh-agent) >/dev/null
ssh-add $HOME/.ssh/id_ed25519 2>/dev/null
fi
# Init cargo / rust
source $HOME/.cargo/env
{{- end }}
{{- if eq .chezmoi.hostname "MacBook-Air-von-Nina" }}
# iTerm2
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# bun
[ -s "/Users/ninagrosse/.bun/_bun" ] && source "/Users/ninagrosse/.bun/_bun"
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# So lazygit can pickup the config
export XDG_CONFIG_HOME="$HOME/.config"
# To use gnu-tar from homebrew as tar
export PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"
{{- end }}
{{- if eq .chezmoi.hostname "RTY-6495672069" }}
alias winhome="cd /mnt/c/Users/GROS145"
# Set JAVA_HOME, so java 17 is used and not java 23 installed through homebrew
export JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-amd64
export PATH=$JAVA_HOME:$PATH
# maven config
export M2_HOME=/home/linuxbrew/.linuxbrew/Cellar/maven/3.9.9
export M2=$M2_HOME/bin
export MAVEN_OPTS='-Xms256m -Xmx512m'
export PATH=$M2:$PATH
{{- end }}
############################################################################
### Autostart Zellij on shell creation, if it's not already running.
### This needs to be at the very end of .zshrc
############################################################################
if [[ -z "$ZELLIJ" && "$ZELLIJ_AUTO_START" == "true" ]]; then
za
fi
# vim:filetype=zsh