-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.aliases.sh
executable file
·575 lines (488 loc) · 17.1 KB
/
.aliases.sh
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
#!/bin/bash
# shellcheck disable=SC2039
# shellcheck disable=SC2155
# shellcheck disable=SC2050
proton() {
export STEAM_COMPAT_CLIENT_INSTALL_PATH="$HOME/.steam/steam"
export STEAM_COMPAT_DATA_PATH=$PWD
local proton_bin="$HOME/.steam/root/compatibilitytools.d/GE-Proton9-5/proton"
"${proton_bin}" run $@
}
dosrun () {
dosbox "$@" -fullscreen -exit
}
loadenv () {
local env_file="$1"
if [[ ! -f $env_file ]]; then
printf "File '$env_file' doesn't exists!"
return 1
fi
export $(cat ${env_file} | xargs)
}
emacs-lite () {
local lite="~/.emacs.d.lite"
emacs -q --eval "(setq user-emacs-directory \"$lite\")" \
-l "$lite/init.el" "$@"
}
emacs-prelude () {
local prelude="$HOME/.emacs.d.prelude"
emacs -q --eval "(setq user-emacs-directory \"$prelude\")" \
-l "$prelude/init.el" "$@"
}
set-default-emacs () {
local emacs_type="$1"
local emacs_d="$HOME/.emacs.d"
local new_emacs_d="$HOME/.emacs.d.${emacs_type}"
if [[ ! -d "$new_emacs_d" ]]; then
printf "error: dir $new_emacs_d not found"
return 1
fi
if [[ -L "${emacs_d}" ]]; then
unlink $emacs_d
elif [[ -d "${emacs_d}" ]]; then
echo "error: ${emacs_d} not a symlink, not a modular emacs config"
return 1
fi
ln -r -v -s "${new_emacs_d}" "${emacs_d}"
}
gclone () {
local repo="$1"
git clone "[email protected]:$repo.git" "${@:2}"
}
function chroot-bind {
sudo mount --rbind /dev dev
sudo mount --rbind /run run
sudo mount --rbind /proc proc
sudo mount --rbind /sys sys
sudo mount --rbind /home home
}
function dropbox-bind {
local host="$1"
mkdir -p ~/Dropbox
sshfs ${host}:Dropbox ~/Dropbox
}
function ftp-start {
sudo service pure-ftpd start
}
function ftp-stop {
sudo service pure-ftpd stop
}
function ftp-status {
sudo service pure-ftpd status
}
function hack-chat {
docker run -d --name hchat \
--restart=unless-stopped \
-p 8001:8080 \
-p 6060:6060 \
-e WSPROTOCOL="ws://" \
-e WSPORT="6060" \
-e WSBASEURL="" \
-e ADMIN_NAME="boop" \
-e PASSWORD="pass" \
-e SALT="2dSg4kS" \
mcgriddle/hack-chat:latest
}
function hack-chat-nginx {
# to deploy over internet
docker run -d --name hchat \
-p 8001:8080 \
-p 6060:6060 \
--restart=unless-stopped \
-e WSPROTOCOL="wss://" \
-e WSPORT="443" \
-e WSBASEURL="/chat-ws" \
-e ADMIN_NAME="boop" \
-e PASSWORD="pass" \
-e SALT="2dSg4kS" \
mcgriddle/hack-chat:latest
}
function filebrowser {
touch $HOME/.filebrowser.db
docker run -d --name filebrowser \
--restart=unless-stopped \
-v $HOME:/srv \
-v $HOME/.filebrowser.db:/database.db \
-v /mnt:/srv/mnt \
-u $(id -u):$(id -g) \
-p 9000:80 \
filebrowser/filebrowser
}
# for monitoring
function netdata {
docker run -d --name=netdata \
--pid=host \
--network=host \
-v netdataconfig:/etc/netdata \
-v netdatalib:/var/lib/netdata \
-v netdatacache:/var/cache/netdata \
-v /etc/passwd:/host/etc/passwd:ro \
-v /etc/group:/host/etc/group:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /etc/os-release:/host/etc/os-release:ro \
-v /var/log:/host/var/log:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--restart unless-stopped \
--cap-add SYS_PTRACE \
--cap-add SYS_ADMIN \
--security-opt apparmor=unconfined \
netdata/netdata
}
function lisp-inference-server {
docker run --name logic \
-p 40000:40000 \
--restart=unless-stopped \
-d -t \
ryukinix/lisp-inference
}
restart-network () {
killall -q -9 nm-applet || true
sudo rc-service -s NetworkManager stop
sudo rc-service net.wlp3s0 restart
}
shutdown-docker () {
sudo rc-service docker stop
sudo ip link del dev docker0 2>/dev/null || true
}
cl-jupyter () {
docker run \
--network=host \
-it \
neowaylabs/common-lisp-jupyter \
jupyter notebook --ip=127.0.0.1
}
u-root-boot () {
sudo qemu-system-x86_64 \
-kernel /boot/vmlinuz-linux \
-initrd /tmp/initramfs.linux_amd64.cpio \
-append "console=ttyS0" \
-nographic \
-no-reboot \
-net nic,model=rtl8139
}
daemonize () {
("$@" &> /dev/null&) &> /dev/null&
}
filter-prime () {
factor "$@" | grep -E '^(.*): \1$' | cut -d':' -f 2 | tr -d ' '
}
# function to run .el files
emacs-run () {
emacsclient -e "(load '$(pwd)/$1')"
}
common-lisp-jupter () {
docker run --network=host -it \
neowaylabs/common-lisp-jupyter jupyter \
notebook --ip=127.0.0.1
}
# receive the first argument, eval it and copy the result to clipboard.
# used to generate easy functions pastebin-like, as termbin and ixx
_pastebin-generic () {
link=$(eval "$1" 2> /dev/null | tr -d "\n")
# shellcheck disable=SC2181
if [ "$?" -eq '0' ]; then
printf "%s" "$link" | xclip -selection clipboard
printf "Copied '%s' to X clipboard.\n" "$link"
fi
}
termbin () {
_pastebin-generic 'nc termbin.com 9999'
}
dot () {
GIT_DIR=$HOME/.dot GIT_WORK_TREE=$HOME git "$@"
}
sys () {
GIT_DIR=/cfg GIT_WORK_TREE=/ git "$@"
}
dotk () {
GIT_DIR=$HOME/.dot GIT_WORK_TREE=$HOME gitk "$@"
}
dotg () {
GIT_WORK_TREE=$HOME gitg $HOME/.dot "$@"
}
env-up () {
# shellcheck disable=SC1090
source "$1/bin/activate"
}
s3-mkdir () {
local bucket="$1"
local folder="$2"
aws s3api put-object --bucket "$bucket" --key "$folder"
}
gccrun () {
gcc "$@" -o a.out; ./a.out; rm -f a.out
}
gateway () {
route | head -n 3 | tail -n 1 | awk '{print $2}'
}
check-ssh-agent-pid () {
local LIST=$(echo "$(pgrep ssh-agent)" "$(pgrep gnome-keyring-d)" | tr '\n' ' ')
local VALUE="$SSH_AGENT_PID"
local SEARCH=$(echo "$LIST" | xargs -n1 echo | grep -E "^$VALUE\$")
# echo LIST: $LIST
# echo VALUE: $VALUE
# echo SEARCH: $SEARCH
echo "$SEARCH"
}
ssh-auth () {
local ssh_agent_pid=$(check-ssh-agent-pid)
local ssh_session_file=/tmp/ssh
if [[ $SSH_AUTH_SOCK == *"/keyring/ssh" ]]; then
echo "[info] SSH auth with gnome-keyring-daemon."
if ! ssh-add -L; then
echo "[warn] no ssh credentials was found, setting up implicitly"
gnome-keyring-daemon -c ssh
ssh-add
fi
else
if [[ -z $(check-ssh-agent-pid) ]]; then
# read session-wise variable
if [ -f /tmp/ssh ]; then
# shellcheck disable=SC1091
source /tmp/ssh
echo "[info] read /tmp/ssh variable sessions"
fi
# try again check ssh agent-pid
ssh_agent_pid=$(check-ssh-agent-pid)
fi
if [[ -z "$ssh_agent_pid" || ! ssh-add > /dev/null ]]; then
# delete old variables
rm -rf /tmp/ssh
# kill old agents
echo "[info] kill all currently ssh-agent"
killall ssh-agent
# create new session
echo "[info] spawn new ssh-agent"
eval "$(ssh-agent)"
export SSH_AGENT_PID
export SSH_AUTH_SOCK
# save variables session-wise to filesystem
touch $ssh_session_file
echo "export SSH_AGENT_PID=$SSH_AGENT_PID" >> $ssh_session_file
echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $ssh_session_file
echo "[info] saved ssh auth variables into $ssh_session_file "
# add ssh key
echo "[info] add default ssh key"
ssh-add
elif [ -z "$(ssh-add -l)" ]; then
# if there is a agent, but no keys, just add it
echo "[info] found a ssh agent working, but there is no keys."
ssh-add
else
echo "[info] SSH auth ok!"
fi
fi
}
ssh-remember () {
# use seahorse to remember password
/usr/lib/x86_64-linux-gnu/seahorse/seahorse-ssh-askpass ~/.ssh/id_rsa > /dev/null
}
sum-lines () {
awk '{s+=$1} END {print s}'
}
drun () {
docker run -it --rm "$@"
}
venv () {
[[ ! -d .venv ]] && python3 -m venv .venv
cd . || exit 1
}
git-remember() {
# cache my https password for 1 week
git config --global credential.helper 'cache --timeout=604800'
}
git-default-branch() {
git remote set-head origin --auto &> /dev/null
git symbolic-ref refs/remotes/origin/HEAD | cut -d / -f 4
}
git-branch-clean() {
local default_branch=`git-default-branch`
git checkout ${default_branch}
git remote prune origin
if [[ $1 == '-f' ]]; then
git branch | egrep -v "(^\*|${default_branch}|dev)" | xargs -r git branch -D
else
git branch --merged | egrep -v "(^\*|${default_branch}|dev)" | xargs -r git branch -d
fi
}
ipv6-disable() {
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
}
nvidia-recompile-and-restart-x() {
local nvidia_module=`dkms status | grep nvidia | cut -d ',' -f 1`
local kernel_version=$(uname -r)
sudo dkms install $nvidia_module -k $kernel_version --force
sudo rc-service xdm restart
}
research () {
local f="$1"
ln -v -s "$(readlink -f "$f")" /home/lerax/Dropbox/University/TCC/research/
}
docker-inspect-command () {
local name="$1"
docker inspect \
--format "$(curl -s https://gist.githubusercontent.com/efrecon/8ce9c75d518b6eb863f667442d7bc679/raw/run.tpl)" \
"$name"
}
# save definition of dot (graphviz language)
alias dot-graph='/usr/bin/dot'
alias dot-tig='GIT_DIR=$HOME/.dot/ tig'
alias dot-gitg='GIT_DIR=$HOME/.dot/ gitg'
alias emacs="emacsclient -nw -a emacs"
alias semacs='SUDO_EDITOR="emacs-lite -nw" sudoedit' #
alias svim='SUDO_EDITOR="vim" sudoedit'
alias remacs='sudo /etc/init.d/emacs.lerax restart'
if which systemctl &> /dev/null; then
alias remacs='systemctl --user restart emacs'
fi
alias agenda='gcalcli agenda'
alias dotnet-build='msbuild'
alias sbcl='rlwrap sbcl --noinform'
alias lisp='sbcl'
alias lain=lein
alias dic=sdcv
# don't use nosetests anymore, is legacy broken and fucked
alias nosetests='nose2'
alias workstar-bind-up='ssh -Y lerax@workstar -t "x2x -north -to :0.0"'
alias workstar-bind-left='ssh -Y lerax@workstar -t "x2x -west -to :0.0"'
alias workstar-bind-right='ssh -Y lerax@workstar -t "x2x -east -to :0.0"'
alias workstar-bind-down='ssh -Y lerax@workstar -t "x2x -south -to :0.0"'
alias workstar='ssh lerax@workstar'
alias starfox-bind-up='ssh -C -Y lerax@starfox -t "x2x -north -to :0.0"'
alias starfox-bind-left='ssh -C -Y lerax@starfox -t "x2x -west -to :0.0"'
alias starfox-bind-right='ssh -C -Y lerax@starfox -t "x2x -east -to :0.0"'
alias starfox-bind-down='ssh -C -Y lerax@starfox -t "x2x -south -to :0.0"'
alias starfox='ssh lerax@starfox'
alias celeste-bind-up='ssh -C -Y lerax@celeste -t "x2x -north -completeregionlow 768 -to :0.0"'
alias celeste-bind-left='ssh -C -Y lerax@celeste -t "x2x -west -completeregionlow 768 -to :0.0"'
alias celeste-bind-right='ssh -C -Y lerax@celeste -t "x2x -east -completeregionlow 768 -to :0.0"'
alias celeste-bind-down='ssh -C -Y lerax@celeste -t "x2x -south -completeregionlow 768 -to :0.0"'
alias celeste='ssh lerax@celeste'
# xclipboard
alias xcopy='xclip -selection clipboard'
alias xpaste='xclip -o -selection clipboard'
function xcopy-ssh {
local host="$1"
ssh -q -X "$host" -t "DISPLAY=:0 xclip -o -selection clipboard" \
| xcopy
}
alias ufc='cd ~/Dropbox/University/Courses/UFC/'
# you need tmate to use that
alias ssh-share='tmux detach -E "tmate && zsh"'
# mouse driver
alias mouse-driver="ratslap"
# making docker life more easy
alias dc=docker
alias dcp='docker-compose'
alias sprunge="curl -F 'sprunge=<-' http://sprunge.us"
alias sprungex='sprunge | xcopy'
alias pastebin=termbin
alias tmate="tmux detach-client -E 'tmate;tmux'"
alias stack-size='ulimit -s'
# pacman aliases
alias pacman-install='sudo pacman -S'
alias pacman-update='sudo pacman -Sy'
alias pacman-upgrade='sudo pacman -Syuu'
alias pacman-search='pacman -Ss'
alias pacman-remove='sudo pacman -Rsu'
alias pacman-reinstall-all='sudo pacman -S $(pacman -Qeqn) --noconfirm'
alias service='sudo rc-service'
alias aur=yay
alias aur-install='aur -S'
alias aur-upgrade='aur -Syuua --overwrite "*"'
alias examples=tldr
alias monitor-off='xset -display :0.0 dpms force off'
alias monitor-on='xset -display :0.0 dpms force on'
alias pdf=llpp
alias qemu=qemu-system-x86_64
alias lelerax='cd ~/Desktop/workspace/lelerax; ./repl'
alias encrypt='gpg -se -r manoel'
alias decrypt='gpg -q --decrypt'
# pip install ipykernel
alias jupyter-create-kernel='ipython kernel install --user --name'
alias distro='cat /etc/os-release | grep "^NAME=" | cut -d"=" -f 2 | tr -d \"'
alias telegram-disable='chmod -x ~/.Telegram/Telegram'
alias telegram-enable='chmod +x ~/.Telegram/Telegram'
alias env-down='deactivate'
alias pyenv-init='eval "$(pyenv init -)"'
alias pipi='pip install --user'
alias rot13="tr 'A-Za-z' 'N-ZA-Mn-za-m'"
alias xfdesktop-shadow-fix='xfconf-query -c xfce4-desktop -p /desktop-icons/center-text -n -t bool -s false'
alias docker-clean='docker system prune'
alias android-up='jmtpfs'
alias android-down='fusermount -u'
alias json=gron
alias reload-aliases='source ~/.aliases.sh'
alias battery=acpi
alias ungron='gron --ungron'
alias histogram='sort | uniq -c'
alias scp-continue='rsync -P -e ssh'
alias hcf='sudo halt'
alias keyboard-thinkpad='setxkbmap -model thinkpad60 -layout br'
alias keyboard-abnt2='setxkbmap -model abnt2 -layout br'
alias open='xdg-open'
alias ssh-ustar="gcloud compute ssh --zone=us-central1-c lerax@ustar"
alias duhere="du -h -d 1 | sort -h -k 1"
alias git-amend="git commit --amend --no-edit"
alias merge='meld'
alias artix-news-summary='artix-news -s'
alias awesome-restart='echo awesome.restart() | awesome-client'
alias no='yes | tr "y" "n"'
alias git-push-all='git remote | xargs -L 1 -I@ git push'
alias python-server='python -m http.server'
alias dr='docker run --rm -it'
alias chown-here='chown -R lerax:lerax .'
alias ustar='ssh ustar'
alias networks='wicd-curses'
alias drive-upgrade='go get -u github.com/odeke-em/drive/cmd/drive'
alias ap='create_ap'
alias benchmark='hyperfine'
alias gcloud-shell='gcloud alpha interactive'
alias startxemacs='tmux detach-client -E startx'
alias terminal='xfce4-terminal'
alias rasp='ssh rasp'
alias pip='pip3'
alias python='python3'
alias commits='git --no-pager log --oneline master..@'
alias tunnels="lsof -i -n | egrep '^ssh\b'"
alias celeste-resolution="xrandr --output LVDS1 --mode 1366x768 --rate 60"
alias git-commit-stage="git reset --soft @~1"
alias makedeb="sudo checkinstall"
alias ptime="ps -o etime= -p"
alias rsync-ssh-push='rsync -r ~/.ssh /keybase/private/lerax/.ssh'
alias rsync-ssh-pull='rsync -r /keybase/private/lerax/.ssh ~/.ssh'
alias wemacs='ssh -Y workstar -t gemacs -c'
alias git-message='git log --format=%B -n 1'
alias dcshell='docker run --rm -it --entrypoint=/bin/bash'
alias battery-headset='bluetooth_battery $(bluetoothctl paired-devices | grep TUNE500BT | cut -d " " -f2).1'
alias pulseaudio-restart='pulseaudio -k; pulseaudio -D'
alias telegram-off='sudo chmod -x `which telegram-desktop | head -n 1`'
alias telegram-on='sudo chmod +x `which telegram-desktop | head -n 1`'
alias awesome-quit="awesome-client 'awesome.quit()'"
alias tcc='cd ~/Dropbox/University/TCC'
alias python-linters-install='pip install flake8 mypy black black-macchiato'
alias docker-kill-all="docker ps | awk '{print \$1}' | tail -n +2 | xargs docker kill"
alias prun='pdm run'
alias raspberry-bind='ssh -C -Y lerax@raspberry -t "x2x -north -to :0.0"'
alias dropbox-ignore='attr -s com.dropbox.ignored -V 1'
alias dropbox-ignore-undo='attr -r com.dropbox.ignored'
alias raspberry="ssh lerax@raspberry"
# ref: https://www.reddit.com/r/gnome/comments/h9drsb/disable_superp_or_change_default_display_layout/
alias disable-super-p="gsettings set org.gnome.mutter.keybindings switch-monitor \"['XF86Display']\""
alias enable-super-p="gsettings reset org.gnome.mutter.keybindings switch-monitor"
alias fix-wayland-not-show-snap-apps="gsettings reset org.gnome.shell app-picker-layout"
alias apps="cd ~/RetroPie/roms/apps"
alias raspi-temp="vcgencmd measure_temp | egrep -o '[0-9]*\.[0-9]*'"
alias retropie-setup="cd ~/Desktop/RetroPie-Setup/; sudo ./retropie_setup.sh"
alias dbx=distrobox
alias workspace="cd ~/Desktop/workspace"
alias ubuntu-upgrade="sudo apt update; sudo apt upgrade -y; sudo apt dist-upgrade -y"
alias apt-remove-all="sudo apt purge --auto-remove"
alias web="cd ~/Dropbox/Programming/Projects/Website/ryukinix.github.io/"
alias avi2mkv='ls -b -1 | grep avi | xargs -I@ echo ffmpeg -fflags +genpts -i @ -c:v libx265 -crf 22 -preset slow -c:a libopus -b:a 192k @x | sed "s/avix/mkv/g" | xargs -I@ bash -c "@"'
alias git-tag-latest="git describe --tags --abbrev=0 2> /dev/null "
alias dfx="df -x overlay -x tmpfs -x devtmpfs"