blob: c205a9bc18ae7b423c4e0e4751618640a682ddb5 (
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
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
|
########## Aliases ##########
# Define alias for nvim/vim (fallback to vim)
if command -v nvim > /dev/null; then
alias vi='nvim'
else
alias vi='vim'
fi
#alias vv='$(history -p !vim)'
alias vv="vim -c 'norm! ^O'"
# Confirmation #
alias mv='mv -i'
alias cp='cp -i'
alias ln='ln -i'
# Disable 'rm'
#alias rm='function _rm() { echo -e "\033[0;31mrm\033[0m is disabled, use \033[0;32mtrash\033[0m or \033[0;32mdel \033[0m\033[0;33m$1\033[0m"; }; _rm'
#alias del='/bin/rm'
# Use lsd for ls if available
if command -v lsd >/dev/null 2>&1; then
alias ls='lsd --color=auto --group-directories-first'
fi
# ls variants
alias l='ls -FAh --group-directories-first'
alias la='ls -lAFh --group-directories-first'
alias lt='ls -lFAht --group-directories-first'
alias lr='ls -RFAh --group-directories-first'
# more ls variants
alias ldot='ls -ld .* --group-directories-first'
alias lS='ls -1FASsh --group-directories-first'
alias lart='ls -1Fcart --group-directories-first'
alias lrt='ls -1Fcrt --group-directories-first'
# ls with different alphabethical sorting
#unalias ll
#ll() { LC_COLLATE=C ls "$@" }
# suffix aliases
alias -g CP='| xclip -selection clipboard -rmlastnl'
alias -g LL="| less exit 2>1 /dev/null"
alias -g CA="| cat -A"
alias -g KE="2>&1"
alias -g NE="2>/dev/null"
alias -g NUL=">/dev/null 2>&1"
alias grep='grep --color=auto --exclude-dir={.git,.svn,.hg}'
alias egrep='egrep --color=auto --exclude-dir={.git,.svn,.hg}'
alias egrep='fgrep --color=auto --exclude-dir={.git,.svn,.hg}'
#alias hist="grep '$1' $HISTFILE"
alias hist="history | grep $1"
alias gdb='gdb -q'
alias rust-gdb='rust-gdb -q'
alias cd="cd-clear-ls"
alias clear='newline_clear'
# List upto last 10 visited directories using "d" and quickly cd into any specific one
alias d="dirs -v | head -10"
# Using just a number from "0" to "9"
alias 0="cd +0"
alias 1="cd +1"
alias 2="cd +2"
alias 3="cd +3"
alias 4="cd +4"
alias 5="cd +5"
alias 6="cd +6"
alias 7="cd +7"
alias 8="cd +8"
alias 9="cd +9"
alias sudo='sudo ' # zsh: elligible for alias expansion/fix syntax highlight
alias sedit='sudoedit'
#alias se='sudoedit'
alias se='sudo -e'
alias :q='exit 2>1 /dev/null'
alias disk-destroyer='$(command -v dd)'
alias dd='echo "Warning use command: disk-destroyer"'
alias sc="systemctl"
alias jc="journalctl"
alias jck="journalctl -k" # Kernel
alias jce='sudo journalctl -b --priority 0..3' # error
alias journalctl-error='sudo journalctl -b --priority 0..3'
alias jcssh="sudo journalctl -u sshd"
alias tunnel='ssh -fNTL'
# tty aliases
#if [[ "$TERM" == 'linux' ]]; then
# alias tmux='/usr/bin/tmux -L linux'
#fi
#alias logout="loginctl kill-user $(whoami)"
logout() {
local wm
wm="$(windowManagerName)"
if [[ -n "$wm" ]]; then
echo "Logging out by killing window manager: $wm"
pkill "$wm"
else
echo "No window manager detected!" >&2
fi
}
alias lg="logout"
#alias suspend='systemctl suspend && betterlockscreen -l' # Suspend(sleep) and lock screen if using systemctl
#alias suspend='systemctl suspend' # Suspend(sleep) and lock screen if using systemctl
alias suspend='loginctl suspend' # Suspend(sleep) and lock screen if using systemctl
#alias shutdown='loginctl poweroff' # Suspend(sleep) and lock screen if using systemctl
#alias shutdown='sudo /sbin/shutdown -h'
#alias poweroff='loginctl poweroff'
#alias reboot='loginctl reboot'
alias reboot='sudo reboot'
#alias hibernate='systemctl hibernate' # Hibernate
alias lock='DISPLAY=:0 xautolock -locknow' # Lock my workstation screen from my phone
alias oports="sudo lsof -i -P -n | grep -i 'listen'" # List open ports
alias keyname="xev | sed -n 's/[ ]*state.* \([^ ]*\)).*/\1/p'"
alias wget=wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" # wget does not support environment variables
alias open="xdg-open"
alias pp='getlast 2>&1 |&tee -a output.txt'
#alias lg='la | grep'
alias pg='ps aux | grep'
alias py='python'
alias py3='python3'
alias activate='source ~/.local/share/venv/bin/activate'
alias sha256='shasum -a 256'
alias rgf='rg -F'
alias weather='curl wttr.in/durban'
alias diary='nvim "$HOME/documents/main/inbox/diary/$(date +'%Y-%m-%d').md"'
alias wifi='nmcli dev wifi show-password'
alias ddg='w3m lite.duckduckgo.com'
alias rss='newsboat'
alias vpn='protonvpn'
alias yt-dl="yt-dlp -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' --restrict-filename"
#alias com.obsproject.Studio="obs"
#alias obs="com.obsproject.Studio"
#alias obs-stuido="obs"
# Time aliases
alias utc='TZ=Africa/Johannesburg date'
alias ber='TZ=Europe/Berlin date'
alias nyc='TZ=America/New_York date'
alias sfo='TZ=America/Los_Angeles date'
alias utc='TZ=Etc/UTC date'
alias src='source $ZDOTDIR/.zshrc'
alias p=proxy
alias cheat='~/.scripts/cheat.sh ~/documents/notes/cheatsheets'
alias crypto='curl -s rate.sx | head -n -2 | tail -n +10'
#alias todo='glow "$HOME"/documents/main/notes/TODO.md'
alias todo='$EDITOR "$(find "$HOME"/documents/main -type f -iname "todo.md" | head -n 1)"'
alias android-studio='/opt/android-studio/bin/studio.sh' # android-studio
alias nomachine='/usr/NX/bin/nxplayer' # nomachine
alias firefox="firefox-bin"
alias discord="vesktop-bin"
alias fetch="fastfetch"
alias batt='upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|to full|percentage"'
alias emerge-fetch='sudo tail -f /var/log/emerge-fetch.log'
alias spotify="env LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify %U"
alias proofread='firejail --private --private-tmp --net=none --seccomp --caps.drop=all zathura'
# NVM
if [ -s "$NVM_DIR/nvm.sh" ]; then
nvm_cmds=(nvm node npm yarn)
for cmd in "${nvm_cmds[@]}"; do
alias "$cmd"="unalias ${nvm_cmds[*]} && unset nvm_cmds && . $NVM_DIR/nvm.sh && $cmd"
done
fi
# Kubernetes
if command -v kubectl > /dev/null; then
replaceNS() { kubectl config view --minify --flatten --context=$(kubectl config current-context) | yq ".contexts[0].context.namespace=\"$1\"" ; }
alias kks='KUBECONFIG=<(replaceNS "kube-system") kubectl'
alias kam='KUBECONFIG=<(replaceNS "authzed-monitoring") kubectl'
alias kas='KUBECONFIG=<(replaceNS "authzed-system") kubectl'
alias kar='KUBECONFIG=<(replaceNS "authzed-region") kubectl'
alias kt='KUBECONFIG=<(replaceNS "tenant") kubectl'
if command -v kubectl-krew > /dev/null; then
path=($XDG_CONFIG_HOME/krew/bin $path)
fi
rmfinalizers() {
kubectl get deployment "$1" -o json | jq '.metadata.finalizers = null' | kubectl apply -f -
}
fi
# Castero
castero() {
if [[ -f ~/.local/share/venv/bin/activate ]]; then
. ~/.local/share/venv/bin/activate
fi
command castero "$@"
}
# Zoxide (cd alternative)
if command -v zoxide >/dev/null 2>&1; then
eval "$(zoxide init zsh)"
fi
|