blob: acd9ed53784967760df6f02fd842fc09862998fa (
plain)
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
|
# vim: filetype=zsh
# Hooks
chpwd() {
if [[ -n "$VIRTUAL_ENV" && -f "$VIRTUAL_ENV/bin/activate" ]]; then
local venv_dir="${VIRTUAL_ENV:h}"
if [[ "$PWD" != "$venv_dir"* ]] && (( $+functions[deactivate] )); then
deactivate
fi
fi
for v in .venv venv .env; do
if [[ -f "$v/bin/activate" ]]; then
. "$v/bin/activate"
break
fi
done
}
# Funktionen
source_if_exists() {
if [[ -r "$1" ]]; then
. "$1"
fi
}
# Optionen
setopt AUTO_PARAM_SLASH
unsetopt CASE_GLOB
setopt HIST_SAVE_NO_DUPS
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
source_if_exists "$HOME/.opam/opam-init/init.zsh"
case "$OSTYPE" in
darwin*)
source_if_exists "/opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
source_if_exists "/opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
;;
freebsd*)
source_if_exists "/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
source_if_exists "/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
;;
esac
if (( ${+ZSH_HIGHLIGHT_STYLES} )); then
ZSH_HIGHLIGHT_STYLES[path]='none'
ZSH_HIGHLIGHT_STYLES[path_prefix]='none'
fi
bindkey -v
export KEYTIMEOUT=1
# Keybindings
zmodload zsh/complist
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
autoload -Uz surround
zle -N delete-surround surround
zle -N add-surround surround
zle -N change-surround surround
bindkey -M vicmd cs change-surround
bindkey -M vicmd ds delete-surround
bindkey -M vicmd ys add-surround
bindkey -M visual S add-surround
bindkey '^A' vi-beginning-of-line
bindkey '^E' vi-end-of-line
# Aliase
alias mc='mc -u'
alias gdb='gdb -q'
alias pwgen='pwgen -s 48 1'
alias ls='ls -G'
# Funktionen
npm-update() {
npm update -g --loglevel=info
}
nvim-update() {
nvim --headless \
-c "lua require[[lazy]].sync({ wait = true })" \
-c "UpdateParsers" \
-c "qa"
}
pkg-update() {
case "$OSTYPE" in
darwin*)
brew update && brew upgrade
;;
freebsd*)
doas pkg update && doas pkg upgrade
;;
*)
print -u2 "pkg-update: kein Paketmanager für $OSTYPE hinterlegt"
return 1
;;
esac
}
pkg-clean() {
case "$OSTYPE" in
darwin*)
brew autoremove
;;
freebsd*)
doas pkg autoremove
;;
*)
print -u2 "pkg-clean: kein Paketmanager für $OSTYPE hinterlegt"
return 1
;;
esac
}
system-update() {
npm-update || return
nvim-update || return
pkg-update || return
if [[ "$1" == "--clean" ]]; then
pkg-clean
fi
}
# Command completion
autoload -U compinit
compinit
_comp_options+=(globdots) # With hidden files
# ... Angular CLI
if (( $+commands[ng] )); then
. <(ng completion script)
fi
zstyle ':completion:*' completer _extensions _complete _approximate
zstyle ':completion:*' menu select
zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f'
zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}!- %d (errors: %e) -!%f'
zstyle ':completion:*:*:*:*:messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:*:*:*:*:warnings' format ' %F{red}-- no matches found --%f'
zstyle ':completion:*' group-name ''
# Prompt
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
RPROMPT=\$vcs_info_msg_0_
PROMPT=$'[%F{green}%8>..>%n%>>%F{white}@%F{green}%8>..>%m%>>%F{white}] %F{white}%(4~|.../%3~|%~) %B%F{blue}>%f%b '
zstyle ':vcs_info:*' unstagedstr ' *'
zstyle ':vcs_info:*' stagedstr ' +'
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%a%u%c%F{3}|%F{1}%a%F{5}]%f'
zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%u%c%F{5}]%f'
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
unfunction source_if_exists
|