-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aliases
343 lines (321 loc) · 8.71 KB
/
.aliases
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#########################
# ALIAS #
#########################
alias EA="nvim ~/.aliases"
mkdot() {
if [ -z "$1" ];then
echo "You must specify a path"
return 1
else
readonly DOTF=`realpath ${DOTF?"$HOME/.dotfiles"}`
readonly SOURCE="$1"
readonly DEST="$DOTF/${SOURCE%$HOME}"
echo "Source:\t$SOURCE"
echo "Dest:\t$DEST"
echo "Dotf:\t$DOTF"
if ! [ -d "$DOTF" ]; then
echo "'$DOTF' is an invalid directory"
return 1
fi
if ! [ $1 = "$HOME*" ]; then
echo "Paths outside of '$HOME' are currently unsupported"
return 1
fi
if ! [ -d "$SOURCE" || -f "$SOURCE" ]; then
echo "Dotfile must be a file or directory!"
return 1
fi
if [ -e "$DEST" ]; then
echo "Dotfile already exists at '$DEST'!"
return 1
fi
#mv "$SOURCE" "$DEST"
#ln -s "$DEST" "$SOURCE"
fi
}
function exp-path() {
SEL="$(readlink -f $1)"
export PATH="$PATH:$SEL"
}
function aurcommit() {
MSG=$*
if [[ -z "$1" ]]; then
read -p "Message: " MSG
fi
updpkgsums
makepkg --printsrcinfo > .SRCINFO
git add PKGBUILD .SRCINFO
namcap PKGBUILD
git commit -m "$MSG"
}
eval $(thefuck --alias)
alias f="fuck"
### CLI & APPLICATIONS
exportvar () {
readonly NAME=${1:?"Specify the name of the variable"}
read VALUE
export $NAME="$VALUE"
}
alias s="sudo"
alias sudo='sudo ' # for using other alias when using sudo
function reload {
if [[ $SHELL == */tmux ]] ; then
exec zsh
else
exec $SHELL # reload whatever is $SHELL
fi
}
alias ar="paru"
alias open="xdg-open"
alias tm="tmux"
alias tma="tmux attach"
alias tmr="tmux source-file ~/.tmux.conf"
alias tmks="tmux kill-server"
if command -v nvim &> /dev/null; then
alias v="nvim"
fi
alias sv='sudo v'
#vns() {
# if [ -z "$1" ];then
# echo "You must specify a path!"
# else
# if [ -e "$1" ];then
# echo "'$1' already exists!"
# return 1
# fi
#
# local SHEBANG="#!/bin/sh"
# echo "$SHEBANG" >> "$1"
#
# if ! [ -f "$1" ]; then
# echo "Could not find created file"
# return 1
# fi
#
# chmod +x "$1"
# if ! [ -x "$1" ];then
# echo "Failed to append execute permissions"
# return 1
# fi
#
# if [ -f "$1" ]; then
# v "$1"
# fi
# fi
#}
alias g="git"
function adjust_date {
date -d "$(date) $@"
}
function ag {
local DATE=$(adjust_date $1)
echo $DATE
GIT_COMMITTER_DATE="$DATE" git commit --amend --date="$DATE" --no-edit
}
git-inspect-status() {
for f in ./*; do;
if [ -d "$f" ]; then
echo $f
git -C $f status -sb -uall
fi
done
}
alias n="npm"
alias nx="npx"
alias p="pnpm"
alias px="pnpm dlx"
alias pr="pnpm run"
alias b="bun"
alias bx="bunx"
alias k="kubectl"
alias m="micromamba"
alias h="helm"
alias py="python"
alias vr='v -r'
alias vm="v -M"
alias su="sudo su -"
alias c="cd"
alias clear='printf "\ec"'
### NETWORKING
alias ifa="/sbin/ifconfig -a"
alias ipshow="ip link show"
alias nmds="nmcli device status"
alias nmcs="nmcli connection show"
function nmwg { nmcli connection import type wireguard file "$@" }
alias mc="sudo macchanger"
alias mch="macchanger --help"
alias mcl="macchanger -l"
alias mcs="macchanger -s"
alias mcr="mc -r"
alias mce="mc -e"
alias mca="mc -a"
alias mcA="mc -A"
alias mcp="mc -p"
alias airm="sudo airmon-ng" # https://github.com/aircrack-ng/rtl8812au
alias airmck="airm check kill"
alias wq="wg-quick"
alias wu="wg-quick up"
alias wd="wg-quick down"
function wr { echo -e "wg-quick down\n"; wg-quick down "$@"; echo -e "wg-quick up\n"; wg-quick up "$@"; }
alias ipls="sudo ip link set" # reference below from https://stackoverflow.com/questions/55127741/how-do-you-pass-arguments-to-custom-zsh-functions
function iplsd {
readonly face=${1:?"The interface must be specified"}
ipls $1 down
echo "Put interface $1 down"
}
function iplsu {
readonly face=${1:?"The interface must be specified"}
ipls $1 up
echo "Put interface $1 up"
}
function remac {
readonly face=${1:?"The interface must be specified"}
iplsd $1
mcA $1
iplsu $1
}
function unmac {
readonly face=${1:?"The interface must be specified"}
iplsd $1
mcp $1
iplsu $1
}
### SYSTEM
alias ipt="sudo iptables"
alias resetlock="faillock --reset --user $USER"
alias xc="xclip -selection clipboard -i"
alias pg="pgrep" # find process id, `$ pidof` is another viable command alternative
alias grep="grep --color=always"
function GI {
grep -i "$@"
}
function TC {
tr -s ' ' | cut -d " " -f$1
}
function sedhref {
sed -n 's/.*href="\([^"]*\).*/\1/p'
}
alias count="wc -l"
function findexe() {
readonly pid=${1:?"The PID of the process must be specified"}
readlink -f /proc/$1/exe
}
### APPLICATIONS
alias mpv="mpv --hwdec=auto"
function flash {
readonly source=${1:?"Source ISO must be specified"}
readonly target=${2:?"Target Device must be specified"}
sudo dd bs=4M if=$source of=$target status=progress "${@:3}"
}
### FS
sf () {
sshfs -o allow_other "$@"
}
alias ssh-check="ssh -O check"
alias fdisk="sudo fdisk"
alias mount="sudo mount"
alias umount="sudo umount"
alias free="free -hm"
# SSD Benchmark
function fiotest {
readonly testFile=${1:?"Test file must be specified"}
sudo fio --loops=5 --size=1000m --filename=$testFile --stonewall --ioengine=libaio --direct=1 \
--name=Seqread --bs=1m --rw=read \
--name=Seqwrite --bs=1m --rw=write \
--name=512Kread --bs=512k --rw=randread \
--name=512Kwrite --bs=512k --rw=randwrite \
--name=4kQD32read --bs=4k --iodepth=32 --rw=randread \
--name=4kQD32write --bs=4k --iodepth=32 --rw=randwrite
sudo rm -ivf $testFile
}
alias fdd='find . -type d -name' # find directory
alias fff='find . -type f -name' # find file
alias du="du -h"
alias df="df -h"
alias du1="du -d 1" # view the size of all directories of depth 1
dutop() {
SOURCE=$1
if [ SOURCE=="" ]; then
du -hsx -- * | sort -rh | head -10
else
du -hsx -- $SOURCE | sort -rh | head -10
fi
}
tdur() {
local P="$1"
if [ -z "$P" ]; then
#P=./*
echo -e "No path specified. Scanning all contents of working directory.\n\n"
return 1
else
echo -e "Using path specified: '$P'\n\n"
fi
exiftool -n -p '\${Duration;our\$s;\$_=ConvertDuration(\$s+=\$_)}' $P|tail -n1
}
alias stripexif="exiftool -all:all= -tagsfromfile @ -exif:Orientation"
#alias cf="count-files"
#alias count-files="ls | wc -l"
#alias cfr="count-files-recursive"
#alias count-files-recursive="ls -R | wc -l"
#alias ducks="du -cks -- * | sort -rn | head"
##### LS
if command -v exa &> /dev/null; then
alias ls="exa -@ --time-style iso --octal-permissions --no-permissions"
fi
alias la='ls -alhg --color=always --group-directories-first'
alias lag="la | grep --color=always ''"
alias lad="la | grep --color=always '^d'"
alias laf="la | grep --color=always '^-'"
alias lar="ls -R --color=always" # show all directories recursively, useful for small directories
##### LS LESS
alias lal="la | less"
alias lldl="lld | less"
alias llfl="llf | less"
### FILE OPERATIONS
alias remount="sudo mount -av"
alias chmox='sudo chmod +x'
alias chowm="sudo chown $USER:$USER -v"
alias mkd="mkdir -vp"
alias smkd="sudo mkdir -vp"
function rs {
rsync -ahh --info=progress2,stats1 --partial "$@"
}
function wgt {
NSLASH="$(echo "$1" | perl -pe 's|.*://[^/]+(.*?)/?$|\1|' | grep -o / | wc -l)"
NCUT=$((NSLASH > 0 ? NSLASH-1 : 0))
wget -r -c -np -e robots=off --user-agent=Mozilla/5.0 -nH --relative --cut-dirs=$NCUT -R "index.html*" "$@"
}
alias ydl="yt-dlp"
ydl-video () {
ydl -f "bestvideo[height>=720]+bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --merge-output-format=mkv "$@"
}
ydl-archive () {
ydl-video --write-annotations --write-description --write-info-json --write-all-thumbnails --download-archive downloaded.txt "$@"
}
m3u8-prompt () {
echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
}
function tarp {
readonly source=${1:?"The SOURCE must be specified"}
readonly target=${2:?"The TARGET must be specified"}
program="$3"
if [ -z ${3+x} ]; then
program="pigz -k -6"
fi
echo -e "Using compress program command '$program'\n"
tar --use-compress-program="$program" -cf - -C "$source" . | pv > "$target"
}
alias cp='cp -v'
alias mv='mv -v'
alias rm='rm -v'
alias rmf='rm -f' # removes all prompts
alias rmd="rmdir -v"
### CD
alias ..="cd .."
alias ...="cd ../.."
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'
alias 1='cd -'
alias 2='cd -2'
alias 3='cd -3'