-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.aliases
143 lines (119 loc) · 4.72 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
# shell aliases
##############################
# not so useless things
cheat() { curl cht.sh/$1; } # online man pages
#pgzip() { time tar cf - ${1%/} | pv | pigz > ${1%/}.tar.gz; } # parallel tar gzip
#tarcheck() { tar -ztf $1 > /dev/null && echo -e "\e[32mOk!\e[0m" || echo -e "\e[31mFailed!\e[0m"; } # verify the tar
# parallel tar gzip
targzparallel() {
TARDIR=${1%/}
BYTES="$(du -sb $TARDIR | cut -f1)"
tar cf - $TARDIR \
| tqdm --bytes --total "$BYTES" --desc Processing \
| pigz \
| tqdm --bytes --total "$BYTES" --desc Compressed --position 1 \
> $TARDIR.tar.gz;
unset TARDIR
}
# verify the tar
tarcheck() {
tar -ztf $1 \
| tqdm --unit files --desc Processing > /dev/null
}
targz() { tar -zcvf ${1%/}.tar.gz ${1%/}; gzip -lv ${1%/}.tar.gz; } # standard
targzsafe() { time tar -zcvf ${1%/}.tar.gz ${1%/}; tar -ztf ${1%/}.tar.gz > /dev/null; } # tar-zip and verify the content
untargz() { time tar -zxvf $1 $2;} # untar
alias glgs="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold green)(%cr) %C(bold blue)<%an>%Creset' --stat" # Best git log tree
alias glgl="git log --oneline --decorate --graph --all"
alias gll="git log --oneline --decorate --graph"
# alias gll="git log --oneline --decorate"
alias gpg-list='gpg --list-secret-keys --keyid-format LONG'
alias gpg-export='gpg --armor --export'
alias git-dry-merge='git merge --no-commit --no-ff'
#alias l='exa -la'
#alias la='exa -la'
#alias lg='exa -lah --git'
#alias ll='exa -l'
alias meteo='curl v2.wttr.in'
# alias open_sesame='ssh -v -T -R 43212:localhost:22 [email protected]' # Ali Baba
#alias open_sesame='ssh -TfN -R 43212:localhost:22 [email protected]'
#alias please='sudo' # Let's be nicer
alias publicip='dig +short myip.opendns.com @resolver1.opendns.com'
alias showstat='dstat --cpu --mem --proc --page --disk --top-cpu --top-io --top-mem' # show system perf
alias ta='tmux attach -t'
alias tl='tmux ls'
alias ts='tmux new-session -s'
alias icat='kitty +kitten icat'
alias tmux_reset_ssh='eval $(tmux show-env -s | grep "^SSH_")'
alias l='ls -l'
# k8s aliases
# alias kubectl="minikube kubectl --"
# vim
alias vimdiff='nvim -d'
alias vim=nvim
export EDITOR=nvim
##############################
# OS specific aliases
if [[ -f "/etc/os-release" ]]; then
OS_NAME=`awk -F= '/^NAME/{print $2}' /etc/os-release`
fi
if [[ "$OSTYPE" = "darwin"* ]]; then
# MAC OSX
#echo "Welcome to Mac"
alias update='brew update && brew upgrade && brew cleanup;'
elif [[ $OS_NAME = "Ubuntu" ]]; then
#echo "Welcome to Ubuntu"
alias open='xdg-open'
alias nomore='sudo shutdown -h now'
alias update='sudo apt update && apt list --upgradable'
alias upgrade='sudo apt upgrade'
elif [[ $OS_NAME = "Arch Linux" ]]; then
alias update='sudo pacman -Syu && paru -Syu'
alias open='xdg-open'
else # [[ "$OS_NAME" = "Fedora Linux" ]]; then
alias open='xdg-open'
alias update='sudo dnf update && dnf needs-restarting -r'
alias upgrade='sudo dnf upgrade'
# clipboard
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
fi
unset OS_NAME
##############################
# Setup environment
export GPG_TTY=$(tty)
##############################
# Personal wiki
# Miscs useful things, thank me later!!
# A collection of handy tools
# system : htop, glances, screenfetch, neofetch, exa, yank
# networking : ping, dig, traceroute, nmap, iftop, arp, speed-test, netstat, nslookup, dog, gping, nmcli
# productivity : clcurses, mc
# misc : cointop, cash, spt, weather
# Sysadmin
# lscpu, df, mount, fdisk, lsusb, lspci, free, dmidecode, hwinfo
# Default permissions
# Files: chmod 664 <filename>
# Direc: chmod 775 <dirname>
# Convert png files to mp4 movie using avconv/ffmpeg
# avconv -r 1 -start_number 1 -i <filename>_%04d.png -vf scale=1920:-1 <output_filename>.mp4
# Convert using convert
# convert -delay 100 -loop 0 <filenamestart>*.png <output_filename>.gif
# Clone all forks from github
# curl -s "https://api.github.com/users/lento234/repos?page=1&per_page=100&fork=True" | grep -e 'git_url*' | cut -d \" -f4
# Download file
# wget -e robots=off -r -nc -np -A <filetype1,filetype2,...> <url>
# Slurm
# scontrol update nodename=hades state=resume # bring a node up
# sinfo, salloc, srun, smap
# hardware
# lspci | grep Root # show pci root complex
# lspci -tv | show pci topology
# lstopo --of ascii
# selinux
# sudo setsebool -P selinuxuser_execmod 1
# network
# check listening ports
# lsof -nP -iTCP -sTCP:LISTEN
# iptables
# alias enable_gateway='sudo iptables -t nat -A POSTROUTING -o enp0s25 -j MASQUERADE && sudo iptables -A FORWARD -i bond0 -o enp0s25 -j ACCEPT && sudo iptables -A FORWARD -i enp0s25 -o bond0 -m state --state RELATED,ESTABLISHED -j ACCEPT'