-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aliases
435 lines (396 loc) · 13 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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
#!/bin/bash
#
sqlf(){
fuzz=$(fs -g '.sql$' | fzf --reverse --height 40%)
[ -f "$fuzz" ] || return 0
sqlformat -ask upper $fuzz -o $fuzz
sed -i 's/;--/;\n--/g' $fuzz
sed -i 's/;/;\n\n/g' $fuzz
}
wgc(){
if [ "$1" = "d" ]; then
profile=$(ip a | grep POINTOPOINT | cut -d':' -f2 | tr -d ' ')
sudo wg-quick down $profile
return 0
fi
profile=$(ls /etc/wireguard/ --color=never | fzf)
if [ -n profile ];then
sudo wg-quick up $( echo $profile | cut -d'.' -f1)
fi
}
fr(){
[[ -z $1 ]] && echo 'No find string provided' && return 1
[[ -z $2 ]] && echo 'No replace string provided' && return 1
if [[ -n $3 ]]; then
sed -i "s/$1/$2/g" $3
else
rg "$1" "$(pwd)" | xargs sed -i "s/$1/$2/g"
fi
}
scratch(){
[ -z $1 ] && vim
vim ~/scratchpad/"$1"
}
dbexport(){
for i in $apps; do py manage.py dumpdata "$i" > "$i.json" && echo "exported $i";done
}
dbimport(){
for i in $apps; do py manage.py loaddata "$i.json" && echo "imported $i";done
}
function cd {
builtin cd "$@"
pwd > ~/.zsh/lastdir
}
# restore last saved path
if [ -f ~/.zsh/lastdir ]
then cd "$(cat ~/.zsh/lastdir)"
else
echo "$HOME" > ~/.zsh/lastdir
cd $HOME
fi
swap(){
mv "$1" "$1_" &&
mv "$2" "$1" &&
mv "$1_" "$2"
}
o(){
fuzz=$(rg -j 4 --no-ignore --files ~/ ~/.ssh/ ~/.bin /media/videos | fzf --reverse --height 40%)
[ -f "$fuzz" ] && ([ -n "$1" ] && $1 "$fuzz" || mimeo "$fuzz") || return 0
}
cfg(){
fuzz=$(fs -p ~/dotfiles/ -p ~/dotfiles/.config/ -p ~/.bin/| fzf --reverse --height 40%)
[ -f "$fuzz" ] && ([ -n "$1" ] && $1 "$fuzz" || vim "$fuzz") || return 0
}
vsc(){
fuzz=$(fs -d -p ~/dev -p ~/work -i node_modules | fzf --reverse --height 40%)
[ -d "$fuzz" ] && ([ -n "$1" ] && $1 "$fuzz" || code --ozone-platform=wayland "$fuzz") || return 0
}
ovim(){
fuzz=$(fs -p ~/dev -p ~/work -i node_modules/ -i '.git'| fzf --reverse --height 40%)
[ -f "$fuzz" ] && nvim "$fuzz" || return 0
}
ovimd(){
fuzz=$(fs -d -p ~/dev -p ~/work -i node_modules/ -i '.git'| fzf --reverse --height 40%)
[ -d "$fuzz" ] && nvim --cmd "cd $fuzz" "$fuzz" || return 0
}
pj(){
fuzz=$(fd -t d . $HOME/Projects | fzf --reverse --height 40%)
if [ -z $fuzz ]
then
return 0
elif [ -d $fuzz ]
then
cd "$fuzz" && reset
fi
}
mntj(){
fuzz=$(fd -t d . $HOME/ | fzf --reverse --height 40%)
if [ -z $fuzz ]
then
return 0
elif [ -d $fuzz ]
then
cd "$fuzz" && reset
fi
}
j(){
fuzz=$(fd -t d . $HOME $HOME/Music/ $HOME/Videos | fzf --reverse --height 40%)
if [ -z $fuzz ]
then
return 0
elif [ -d $fuzz ]
then
cd "$fuzz" && reset
fi
}
ol(){
fuzz=$(rg --files | fzf --reverse --height 40%)
[ -f "$fuzz" ] && ([ -n "$1" ] && $1 "$fuzz" || mimeo "$fuzz") || return 0
#[ -f "$fuzz" ] && mimeo "$fuzz" || return 0
}
jl(){
fuzz=`fd -Ht d . "$(pwd)" | fzf --reverse --height 40%`
if [ -z $fuzz ]
then
return 0
elif [ -d $fuzz ]
then
if [ "$1" != "mpv" ]
then
cd $fuzz && reset
else
mpv $fuzz & disown
fi
fi
}
mkpw(){
lenth=8
[ ! -z $1 ] && lenth=$1
PW=$(tr -dc 'A-Za-z0-9!$%&*+,-./=?@^_~' </dev/urandom | head -c $lenth)
echo $PW
}
secret(){
echo "$(tr -dc 'A-Za-z0-9!$%&()*+,-./<=>?@[]^_{|}~' </dev/urandom | head -c 50)"
}
py(){
$VIRTUAL_ENV/bin/python "$@"
}
# remind(){
# while getopts d:t:n: flag
# do
# case "${flag}" in
# d) d=${OPTARG}
# delay=$d;;
# t) t=${OPTARG}
# hour=$(date --date="$t" "+%H")
# current_hour=$(date "+%H")
# current_time=$(date "+%s")
# ((hour < current_hour)) &&
# delay=$(($(date --date="$t 1 day" "+%s") - $current_time)) ||
# delay=$(($(date --date="$t" "+%s") - $current_time));;
# n) note=${OPTARG};;
# *) echo 'unknown flag' && return 1
# esac
# done
# (sleep $delay && notify-send "$note" &&
# mpv --force-window=no /usr/share/sounds/freedesktop/stereo/service-login.oga) &> /dev/null & disown
# }
ytd(){
a=
r=
while getopts r:a flag
do
case "${flag}" in
r) r=${OPTARG}
[ "$r" -eq "$r" ] &> /dev/null && continue || echo 'Resolution not an integer' && return 1 ;;
a)
link="${@:${OPTIND}}"
[ $link = '-a' ] && echo 'no link provided' && return 1
yt-dlp --audio-format mp3 -x ${@:(( OPTIND+1 ))} && return 0 ;;
?) echo "unknown flag -${OPTARG}" && return 1
esac
done
link="${@:${OPTIND}}"
[ -z $r ] && r=1080
[ -z $link ] && echo 'no link provided' && return 1
yt-dlp -f "bestvideo[height<="$r"]+bestaudio" $link
}
bt(){
remind -d $1 -n 'Water'
}
pid(){
ps ax | fzf | awk '{print $1}'
}
swapname(){
mv "$1" "$1.tmp" > /dev/null
mv "$2" "$1" > /dev/null
mv "$1.tmp" "$2" > /dev/null
echo "names swapped"
}
unepoch(){
date -d @$1 "+%F %H:%M:%S"
}
venv(){
source $VIRTUAL_ENV/bin/activate
}
pt(){
cd ~/Projects/Foto-Dino/backend-todo/
git add -A
git commit -m 'update todo'
git push
cd -
}
hclient(){
clients=$(hyprctl clients | sed 's/\t//g' | grep -iE 'class|title' | grep -v ': $')
[ ! -z $1 ] && echo $(echo $clients | grep -i $1) || echo $clients
}
localip(){
ip a | grep -E '192.168|10.0' | cut -d ' ' -f6 | cut -d '/' -f1
}
ignore() {
curl -sLw "\n" "https://www.toptal.com/developers/gitignore/api/$@" | grep -v 'http' > .gitignore
echo ".gitignore\n.vscode\n.env" >> .gitignore;
}
aignore(){
echo '\n' >> .gitignore
curl -sLw "\n" "https://www.toptal.com/developers/gitignore/api/$@" | grep -v 'http' >> .gitignore
}
mvshuffle(){
mpv --shuffle "$HOME/Videos/Music Videos/" & disown
}
godoc(){
go doc $1 | bat --language=go
}
# functions
alias lp="l -p"
alias cronhelp=" echo '
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │ 7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * * <command to execute>
'"
alias vim="nvim"
alias kc="kdeconnect-cli -d edd439448e1817fa "$1""
alias move="find . -mindepth 2 -type f -print -exec mv {} . \;"
alias g="| grep"
# alias rfile="grep "$1" /home/ted/Documents/teams/teamfiles"
alias rcopy="rclone copy --progress --no-traverse"
alias rdir="cat /home/ted/Documents/teams/teamdirs | fzf"
alias bp="py -m bpython"
alias pkg="paru -Q | fzf"
alias gd="go doc"
alias fzf="fzf --layout=reverse --height=40%"
alias zz="vim ~/.zprofile"
alias zh="cat ~/.zhistory | fzf"
alias vi="vim"
alias df="df -h" # human-readable size
alias free="free -m" # show sizes in MB
alias more=less
alias update="paru -Syu"
alias get="paru -S"
alias search="paru -Fs"
alias wr="wget -r -np -nH --cut-dirs=3 -p -e robots=off -U mozilla -c -R.html"
alias yl="youtube-dl -f '[height<=480]'"
alias kick="paru -Rns"
alias mv="mv -v"
alias wget="wget -U Mozilla/5.0 -c"
alias s="speedtest --no-up"
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias sudo='sudo '
alias reload="exec ${SHELL} -l; clear"
alias pb="bpython"
alias path='echo -e ${PATH//:/\\n}'
alias al="vim ~/.aliases && clear && reload"
alias smb="sudo vim /etc/samba/smb.conf"
alias mpvhd='mpv --ytdl-format="(best[height<=1080]/bestvideo+bestaudio)"'
alias mpv10='mpv --ytdl-format="(best[height=1080])"'
alias dd='dd status=progress'
# alias python="env python3"
alias ytv="cd ~/Videos/youtube"
alias copy="xclip -sel c < $1"
alias rp="cd ~/Pictures/Redpaper"
alias v="vim ~/.vim/vimrc"
alias z="vim ~/.zshrc"
#alias ytd="youtube-dl -f 'bestvideo[height<=1080]+bestaudio' "$@""
alias rsync="rsync -ah --progress"
alias pq="pacman -Q | fzf"
alias pr="protonvpn r"
alias pd="protonvpn d"
alias feh="feh -d --edit -. -B black ."
alias gst="git status"
alias gch="git checkout"
alias gcm="git checkout main"
alias gcd="git checkout dev"
alias gcs="git checkout staging"
alias gam="git add \*migrations\*"
alias gtm="git commit -m"
alias gcon="git diff --name-only --diff-filter=U"
# alias gmm="git merge "$1" -m "$(git log -1 --pretty=%B $1)""
alias start="sudo systemctl start"
alias stop="sudo systemctl stop"
alias restart="sudo systemctl restart"
alias sysenable="sudo systemctl enable"
alias pipm="python3 -m pip"
alias pyserv="python -m http.server"
alias crontab="export VISUAL=nvim; crontab"
alias myip="curl -s 'https://api.myip.com' | jq"
alias lorem="lazylorem"
alias migrate="/usr/bin/env python manage.py migrate"
alias gomigrate="$HOME/go/bin/migrate"
alias mm="/usr/bin/env python manage.py makemigrations"
alias rs="export DEBUG=True;/usr/bin/env python manage.py runserver 127.0.0.1:8002"
alias xp="xprop | grep WM_CLASS"
alias status="sudo systemctl status"
alias enable="sudo systemctl enable"
alias mlock="multilockscreen"
alias ipy="ipython"
alias yay="paru"
alias kdif="kitty +kitten diff"
alias ex="extract"
# alias less="bat --pager=always"
alias dupe="czkawka_cli"
alias ddev="ssh dino-dev"
alias dutils="ssh dino-utils"
alias dstage="ssh dino-stage"
alias dprod="ssh dino-prod"
alias cvr="coverage run --omit='*/.virtualenvs/*,*/tests_/*' manage.py test "$1""
alias cvs="coverage html"
alias ls="eza --color=always --group-directories-first"
alias ll="eza -l --color=always --group-directories-first"
alias lla="eza -al --color=always --group-directories-first"
alias la="eza -a --color=always --group-directories-first"
alias dshell="py manage.py shell"
alias dbshell="py manage.py dbshell"
alias mpn="mpv --no-resume-playback"
alias cp="cp -r"
alias rr="exec ${SHELL} -l; clear"
alias pc="[ -n $1 ] && sudo netstat -tulnp | grep $1"
alias nu=" ~/Carousel/scripts/netusage/netusage.sh"
alias uctl="systemctl --user"
alias ffhvec="ffmpeg -i $1 -c:v: hevc_nvenc -preset slow -rc vbr -cq 0 -qmin:v 19 -qmax:v 25 -look_ahead 32 -pix_fmt p010le -c:a copy -c:s copy -vf scale=768:480 $2"
alias diffc="diff --text --color"
alias hcs="sudo hwclock -s"
alias codeapi="cd ~/Projects/dino/api/Foto_Dino && code ~/Projects/dino/api"
alias codesala="cd ~/Projects/copysala && code ~/Projects/copysala"
alias codeplay="cd ~/Projects/goplay && code ~/Projects/goplay"
alias codeblog="cd ~/Projects/blog && code ~/Projects/blog"
alias codepenny="cd ~/Projects/pennychart/ && code ~/Projects/pennychart/"
alias codedev="cd ~/Projects/bootdev && code ~/Projects/bootdev"
alias codeknown="cd ~/Projects/known && code ~/Projects/known"
alias raptorcode="code ~/Projects/dino/DinoRatpor"
alias postjson="curl -H 'Content-Type:application/json' -X POST -s"
alias patchjson="curl -H 'Content-Type:application/json' -X PATCH -s"
alias curljson="curl -H 'Content-Type:application/json' -X -s"
alias utc="date +'%Y-%m-%d %H:%M:%S' -d"
alias djangologs="less ~/.api_data/logs/django_debug.log"
alias hserve="hugo serve --noHTTPCache --ignoreCache --disableFastRender --port=9000"
alias denv="less --plain ~/.api_data/local_env"
alias codegoss="cd ~/Projects/gowsc && code ."
alias leetcode="cd ~/Projects/LeetCode && code ."
alias dc="docker compose"
alias dps="docker ps"
alias dcu="docker compose up -d"
alias dcd="docker compose down"
alias dports="docker ps --format \"table {{.Names}}\t{{.Ports}}\""
alias vdc="vim docker-compose.yml"
alias dtoken="grep -i 'ACCESS' ~/.api_data/local_env | cut -d'=' -f2 | clip.exe"
alias gr="go run ."
alias hyprgrep="hyprctl clients -j | grep -v 'grep' | grep $1 -B 12 -A 11"
alias vcfg="cd ~/.config/nvim/ && vim ."
alias du="du -h"
alias nv="neovide"
alias nrs="npm run serve"
alias rsn="npm run serve"
alias rns="npm run serve"
alias h="cat ~/.zhistory | fzf "
alias kmarial="mariadb --defaults-file=~/.local/mariadb/local.db.cnf"
alias smarial="mariadb --defaults-file=~/work/kupiku/Shipping2/ship.cnf"
alias kmariap="mariadb --defaults-file=~/.local/mariadb/prod.db.cnf"
alias dpgl="psql -U kiss -d discogs"
alias dpgp="psql -h 95.216.65.50 -U releases -d discogs -p 5433"
alias wrandr='wlr-randr'
alias kp='cd "$(fs -p ~/work/kupiku/ -d --depth=1 | fzf)"'
alias vpnr="sudo protonvpn d && sudo protonvpn c -cc $1"
alias vpn="sudo protonvpn c --cc"
alias vpnd="sudo protonvpn d"
alias reflect="sudo reflector --latest 20 --sort rate --save /etc/pacman.d/mirrorlist"
alias suspend="sudo systemctl suspend"
alias currencies="smarial -e 'select * from shipping_currencyconversion'"
alias orderstatus="smarial -e 'select * from shipping_orderstatus;'"
alias gears="vkcube"
alias code="code --ozone-platform=wayland"
alias nvc="nvim --cmd \"cd ~/.config/nvim\" ~/.config/nvim"
alias lf="yazi"