-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc.tmpl
240 lines (203 loc) · 6.22 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
# To debug slow ZSH startup time, uncomment following line along with the last line of this file
# #zmodload zsh/zprof
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000000000
SAVEHIST=1000000000
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/nymous/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
#########################
# Setup basic variables #
#########################
DEFAULT_USER="nymous"
export EDITOR="vim"
####################################
# Setup ZSH plugins before loading #
####################################
zstyle :omz:plugins:ssh-agent identities id_ed25519
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
export NVM_LAZY_LOAD=true
export NVM_AUTO_USE=true
# Disable oh-my-zsh autoupdate
DISABLE_AUTO_UPDATE=true
DISABLE_UPDATE_PROMPT=true
####################
# Load ZSH plugins #
####################
autoload -Uz is-at-least compaudit
ZSH="$(antibody home)/https-COLON--SLASH--SLASH-github.aaakk.us.kg-SLASH-robbyrussell-SLASH-oh-my-zsh"
ZSH_CACHE_DIR="${ZSH}/cache"
ZSH_THEME=
source ~/.antibody.sh
#######################
# Lazy load dev tools #
#######################
export PATH="$HOME/.rbenv/bin:$PATH"
# eval "$(rbenv init -)"
rbenv() {
eval "$(command rbenv init -)"
rbenv "$@"
}
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
# eval "$(pyenv init -)"
pyenv() {
eval "$(command pyenv init --path)"
eval "$(command pyenv init -)"
pyenv "$@"
}
#########################
# Add dev tools to PATH #
#########################
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
############################
# Add custom tools to PATH #
############################
export PATH=$PATH:$HOME/.local/bin
export PATH=$PATH:$HOME/go/bin
export PATH=$PATH:$HOME/.cargo/bin
#################################
# Load command-not-found plugin #
#################################
# It requires https://wiki.archlinux.org/index.php/Pkgfile to be installed and automatically updated
source /usr/share/doc/pkgfile/command-not-found.zsh
#########################
# Aliases and functions #
#########################
alias x=startx
alias cat=vimcat
{{- if eq .chezmoi.hostname "architect" }}
alias adeo="xrandr --output HDMI-1-1 --right-of eDP-1-1 && ssh-add ~/.ssh/id_ed25519_adeo"
alias ultrawide="/home/nymous/.screenlayout/ultrawide.sh"
alias battery="cat /sys/class/power_supply/BAT1/capacity"
{{- end }}
### git
alias gc="git commit"
alias gm="git merge --no-ff"
alias gl="git pull --ff-only"
alias gfl="git flow"
alias gfp="git fetch --prune"
alias gpfl="git push --force-with-lease"
alias pacclean="sudo paccache -r"
alias pping="prettyping --nolegend"
### ls
alias ls="lsd"
alias l="ls -lF"
alias la="ls -laF"
### python
alias activate="source ./.venv/bin/activate"
function cdtmp() {
cd $(mktemp -d)
}
alias blue="sudo systemctl start bluetooth && sudo rfkill unblock bluetooth"
# https://wiki.archlinux.org/index.php/Bluetooth_headset & https://github.com/khvzak/bluez-tools/issues/13
function btc {
local BT_DEV=48:44:F7:F6:27:E6
<<<"agent on
trust $BT_DEV
pair $BT_DEV
connect $BT_DEV
quit" bluetoothctl
}
function wpa2_entreprise {
read -r 'ssid?SSID: '
read -r 'identity?Username: '
read -r 'anonymous?Anonymous identity: '
read -rs 'password?Password: '
echo ''
nmcli con add type wifi con-name "$ssid" ifname wlp8s0 ssid "$ssid" wifi-sec.key-mgmt wpa-psk 802-1x.identity "$identity" 802-1x.anonymous-identity "$anonymous" 802-1x.password "$password" 802-1x.eap peap 802-1x.phase2-auth mschapv2
}
function mcd() {
mkdir -p "$1" && cd "$1";
}
function fixlayout() {
setxkbmap -device $(xinput list | grep "Virtual core XTEST keyboard" | sed -e 's/.\+=\([0-9]\+\).\+/\1/') fr
}
function notif() {
case "$1" in
"on")
dunstctl set-paused false
;;
"off")
dunstctl set-paused true
;;
*)
echo "Use notif <on|off> to enable or disable dunst"
;;
esac
}
function ,jwt-decode() {
read 'jwt?JWT: '
jq -R '{"jwt_header": (split(".") | .[0] | @base64d | fromjson), "jwt_signature": (split(".") | .[2]), "jwt_content": (split(".") | .[1] | @base64d | fromjson | (.exp, .iat) |= todateiso8601)}' <<< "$jwt"
}
function ,discord-skip-update() {
CONFIG_PATH=~/.config/discordcanary/settings.json
case "$1" in
"true")
NEW_CONTENT=$(jq '.SKIP_HOST_UPDATE = true' "${CONFIG_PATH}")
echo $NEW_CONTENT > "${CONFIG_PATH}"
;;
"false")
NEW_CONTENT=$(jq '.SKIP_HOST_UPDATE = false' "${CONFIG_PATH}")
echo $NEW_CONTENT > "${CONFIG_PATH}"
;;
*)
echo "Use $0 <true|false> to enable or disable updates for Discord Canary"
;;
esac
}
function ap() {
case "$1" in
"up")
sudo systemctl start create_ap
;;
"down")
sudo systemctl stop create_ap
;;
*)
echo "Use ap <up|down> to start or stop Wifi sharing"
;;
esac
}
function pa-virtual-output() {
pacmd load-module module-null-sink sink_name=VirtualSink sink_properties=device.description=VirtualSink
#pacmd update-sink-proplist VirtualSink device.description=VirtualSink
pacmd load-module module-combine-sink sink_name=CombineVirtualHeadphones slaves=VirtualSink,alsa_output.pci-0000_0e_00.4.analog-stereo
}
function lofi() {
mpv --no-vid --no-audio-display 'https://www.youtube.com/watch?v=5qap5aO4i9A'
}
### systemctl
alias sstart="sudo systemctl start"
alias sstop="sudo systemctl stop"
alias sstatus="systemctl status"
### Magic expand
# See https://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html
globalias() {
if [[ $LBUFFER =~ ' [A-Z0-9]+$' ]]; then
zle _expand_alias
zle expand-word
fi
zle self-insert
}
zle -N globalias
bindkey " " globalias
bindkey "^ " magic-space # control-space to bypass completion
bindkey -M isearch " " magic-space # normal space during searches
#######################################
# Reload completions added by plugins #
#######################################
compinit
##################
# Activate theme #
##################
eval "$(starship init zsh)"
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /usr/bin/vault vault
#zprof