-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc.tmpl
297 lines (252 loc) · 8.07 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
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
292
293
294
295
296
297
# (c) 2024 lvlcn-t - zshrc
# - zsh: https://www.zsh.org/
#
# Preqs: Each prerequisite is listed in the comments above the line that requires it
export LANG=C.UTF-8
sourceIfExists () {
test -f $1 && source $1
}
sourceIfExists $HOME/.env
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt appendhistory
# Brew is a package manager for macOS and Linux: https://brew.sh/
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
if command -v brew &> /dev/null; then
alias du-brew='du -sch $(brew --cellar)/*/* | sed "s|$(brew --cellar)/\([^/]*\)/.*|\1|" | sort -k1h'
fi
# Load the default .profile
[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'
# Zplug is a plugin manager for zsh: https://github.com/zplug/zplug
sourceIfExists "$HOME/.zplug/init.zsh"
if ! command -v zplug &> /dev/null; then
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
source ~/.zplug/init.zsh
fi
unsetopt beep extendedglob nomatch
bindkey -e
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
bindkey "^H" backward-kill-word
bindkey "5~" kill-word
bindkey "^[[3~" delete-char
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Powerlevel10k Configuration - https://github.com/romkatv/powerlevel10k
sourceIfExists "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
sourceIfExists "$HOME/.p10k.zsh" # Customized prompt - run `p10k configure`, or edit ~/.p10k.zsh to change it
# zplug Configuration
zplug "plugins/git", from:oh-my-zsh
zplug "plugins/kubectl", from:oh-my-zsh
zplug "plugins/helm", from:oh-my-zsh
zplug "plugins/command-not-found", from:oh-my-zsh
zplug "plugins/docker", from:oh-my-zsh
zplug "plugins/docker-compose", from:oh-my-zsh
zplug "plugins/dotenv", from:oh-my-zsh
zplug "plugins/jsontools", from:oh-my-zsh
zplug "plugins/asdf", from:oh-my-zsh
zplug "zsh-users/zsh-syntax-highlighting", defer:2
zplug "zsh-users/zsh-completions", defer:2
zplug reegnz/jq-zsh-plugin
zplug romkatv/powerlevel10k, as:theme, depth:1
sourceIfExists "$HOME/.cargo/env"
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
zplug load
# This autoloads the completion scripts for zsh
mkdir -p ~/.zsh/completions
fpath=(~/.zsh/completions $fpath)
fpath+=~/.zfunc
autoload -Uz compinit && compinit
[ -f $HOMEBREW_PREFIX/etc/profile.d/autojump.sh ] && . $HOMEBREW_PREFIX/etc/profile.d/autojump.sh
# eza is a command line tool for file management: https://github.com/eza-community/eza
if command -v eza &> /dev/null
then
alias ls='eza'
alias ll='eza -lah --icons'
alias tree='eza -lah --icons --tree'
fi
if command -v git-town &> /dev/null
then
alias gt="git town"
alias gts="git town sync"
alias gtb="git town branch"
alias gtsw="git town switch"
fi
# docker is a containerization platform: https://www.docker.com/
if command -v docker &> /dev/null
then
# dive is a tool for exploring a docker image: https://github.com/wagoodman/dive
alias dive="docker run -ti --rm -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive"
# jaeger is a distributed tracing platform: https://www.jaegertracing.io/
alias jaeger="docker run -d --name jaeger \
-e COLLECTOR_OTLP_ENABLED=true \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14250:14250 \
-p 14268:14268 \
-p 14269:14269 \
-p 4317:4317 \
-p 4318:4318 \
-p 9411:9411 \
jaegertracing/all-in-one:1.60"
fi
# nvim is a text editor: https://neovim.io/
export PATH="$PATH:/opt/nvim-linux64/bin"
if command -v nvim &> /dev/null
then
alias vim='nvim'
fi
# code-insiders is the insiders version of Visual Studio Code: https://code.visualstudio.com/insiders/
if command -v code-insiders &> /dev/null
then
alias code='code-insiders'
fi
# go is a programming language: https://golang.org/
export PATH=$PATH:/usr/local/go/bin
if command -v go &> /dev/null
then
export PATH=$PATH:$HOME/go/bin # Add go bin directory to PATH, this is where go install puts binaries
export GOPRIVATE=gitlab.devops.telekom.de # Set the GOPRIVATE environment variable to enable private go modules
export GO111MODULE=on # Enable go modules
fi
# kubectl is a command line tool for kubernetes: https://kubernetes.io/docs/reference/kubectl/overview/
if command -v kubectl &> /dev/null
then
source <(kubectl completion zsh)
alias k=kubectl
fi
# kind is a tool for running local kubernetes clusters: https://kind.sigs.k8s.io/
if command -v kind &> /dev/null
then
kind completion zsh > ~/.zsh/completions/_kind
fi
# helm is a package manager for kubernetes: https://helm.sh/
if command -v helm &> /dev/null
then
source <(helm completion zsh)
fi
# gh is the GitHub CLI: https://cli.github.com/
if command -v gh &> /dev/null
then
gh completion -s zsh > ~/.zsh/completions/_gh
gh copilot --version &> /dev/null
if [ $? -ne 0 ];
then
gh extension install github/gh-copilot
fi
eval "$(gh copilot alias -- zsh)"
alias ghc='gh copilot'
# alias ghcs='gh copilot suggest'
# alias ghce='gh copilot explain'
fi
# glab is a GitLab CLI: https://gitlab.com/gitlab-org/cli
if command -v glab &> /dev/null
then
set_gitlab_env() {
netrc=$1
local machine_line password_line host token
while IFS= read -r line; do
if [[ $line == machine* ]]; then
machine_line=$line
elif [[ $line == *password* ]]; then
password_line=$line
host=$(echo $machine_line | awk '{print $2}')
token=$(echo $password_line | awk '{print $2}')
if [[ $host == *gitlab* ]]; then
export GITLAB_HOST="https://$host"
export GITLAB_TOKEN="$token"
return
fi
fi
done < $netrc
}
set_gitlab_env $HOME/.netrc
source <(glab completion -s zsh); compdef _glab glab
alias gpsci='gp -o ci.skip'
fi
if command -v gitlab-ci-local &> /dev/null
then
export GCL_NEEDS='true'
# export GCL_FILE='.gitlab-ci-local.yml'
# export GCL_VARIABLE="IMAGE=alpine:latest"
alias gci='gitlab-ci-local'
fi
# chezmoi is a dotfile manager: https://www.chezmoi.io/
if command -v chezmoi &> /dev/null
then
source <(chezmoi completion zsh)
fi
# az is the Azure CLI: https://docs.microsoft.com/en-us/cli/azure/
if command -v az &> /dev/null
then
if [ -f /etc/bash_completion.d/azure-cli ]; then
autoload -U +X bashcompinit && bashcompinit
source /etc/bash_completion.d/azure-cli
fi
fi
if command -v azd &> /dev/null
then
source <(azd completion zsh)
export AZURE_DEV_COLLECT_TELEMETRY="no"
fi
if command -v func &> /dev/null
then
export FUNCTIONS_CORE_TOOLS_TELEMETRY_OPTOUT="true"
fi
# nvm is a version manager for node.js: https://github.com/nvm-sh/nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# pnpm is a package manager for node.js: https://pnpm.io/
export PNPM_HOME="$HOME/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
{{- if .machine.proxy.enabled }}
export HTTP_PROXY={{ .machine.proxy.http }}
export HTTPS_PROXY={{ .machine.proxy.https }}
export NO_PROXY={{ .machine.proxy.noProxy }}
export http_proxy={{ .machine.proxy.http }}
export https_proxy={{ .machine.proxy.https }}
export no_proxy={{ .machine.proxy.noProxy }}
{{- end }}
{{- if .machine.packages.languages.python }}
if ! command -v pyenv &> /dev/null
then
if [ -d "$HOME/.pyenv" ]; then
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
fi
python_version="3.12"
if ! python3 --version | grep -q ${python_version} &> /dev/null
then
if command -v pyenv &> /dev/null
then
pyenv global ${python_version}
if [ $? -ne 0 ]; then
pyenv install -v ${python_version}
pyenv global ${python_version}
fi
fi
fi
{{- end }}
if command -v yt-dlp &> /dev/null
then
alias yt-mp3='yt-dlp -x --audio-format mp3'
fi
export PATH="/usr/local/bin/bin:$PATH"