-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc.tmpl
167 lines (145 loc) · 3.95 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
# Environment variables need to be declared first, especially Zellij's
export FZF_DEFAULT_COMMAND='fd'
export FZF_CTRL_T_OPTS="--preview '(bat --style=plain --theme=base16 --color=always {} || tree -C {}) 2> /dev/null | head -200' --select-1 --exit-0"
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'"
export TEALDEER_CONFIG_DIR=/Users/eh8/.config/tealdeer
export SOPS_AGE_KEY_FILE="$HOME/.config/sops/age/keys.txt"
export EDITOR=hx
# https://github.com/zellij-org/zellij/issues/1736 Connect to Zellij (create
# named session if not existent) and close shell when leaving Zellij
if [[ -z "$ZELLIJ" ]]; then
zellij attach default || zellij --session default
exit
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
# Read a nifty quote
fortune
# Shortcuts
alias cat='bat --style=plain --theme=base16 --paging=never '
alias e='eza '
alias v='vim '
alias sudo='sudo '
alias z='zellij '
{{ if eq .chezmoi.os "darwin" }}
alias bcubc='brew upgrade --cask && brew cleanup'
alias bcubo='brew update && brew outdated --cask'
alias brewp='brew pin'
alias brewsp='brew list --pinned'
alias bubc='brew upgrade && brew cleanup'
alias bubo='brew update && brew outdated'
alias bubu='bubo && bubc'
alias buf='brew upgrade --formula'
source /opt/homebrew/opt/powerlevel10k/share/powerlevel10k/powerlevel10k.zsh-theme
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Enable zsh completions
if type brew &>/dev/null; then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
autoload -Uz compinit
compinit
fi
{{ else if eq .chezmoi.os "linux" }}
# systemctl aliases
user_commands=(
cat
get-default
help
is-active
is-enabled
is-failed
is-system-running
list-dependencies
list-jobs
list-sockets
list-timers
list-unit-files
list-units
show
show-environment
status
)
sudo_commands=(
add-requires
add-wants
cancel
daemon-reexec
daemon-reload
default
disable
edit
emergency
enable
halt
import-environment
isolate
kexec
kill
link
list-machines
load
mask
preset
preset-all
reenable
reload
reload-or-restart
reset-failed
rescue
restart
revert
set-default
set-environment
set-property
start
stop
switch-root
try-reload-or-restart
try-restart
unmask
unset-environment
)
power_commands=(
hibernate
hybrid-sleep
poweroff
reboot
suspend
)
for c in $user_commands; do
alias "sc-$c"="systemctl $c"
alias "scu-$c"="systemctl --user $c"
done
for c in $sudo_commands; do
alias "sc-$c"="sudo systemctl $c"
alias "scu-$c"="systemctl --user $c"
done
for c in $power_commands; do
alias "sc-$c"="systemctl $c"
done
unset c user_commands sudo_commands power_commands
# --now commands
alias sc-enable-now="sc-enable --now"
alias sc-disable-now="sc-disable --now"
alias sc-mask-now="sc-mask --now"
alias scu-enable-now="scu-enable --now"
alias scu-disable-now="scu-disable --now"
alias scu-mask-now="scu-mask --now"
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
export FZF_BASE=/usr/bin/fzf
source /usr/share/fzf/key-bindings.zsh
source /usr/share/fzf/completion.zsh
# Enable zsh completions
autoload -Uz compinit
compinit
fpath=(/usr/share/zsh/site-functions/ $fpath)
{{ end }}
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh