-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
183 lines (169 loc) · 8.03 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
alias config='git --git-dir=$HOME/dotfiles --work-tree=$HOME'
alias recent="awk -F'file://|\" ' '/file:\/\// {print \$2}' ~/.local/share/recently-used.xbel"
alias meteo='curl wttr.in/Lille'
alias starwars_pic='clear ; while : ; do ack --bar | lolcat --force ; sleep 0.05 ; printf "\e[0;0H" ; done'
alias starwars_history='ssh gabe565.com'
alias mapscii='telnet mapscii.me'
alias mkdir='mkdir -pv'
alias ipinfo='curl ipinfo.io'
alias cleaner='sudo apt purge -y $(dpkg --list |grep "^rc" |awk "{print \$2}") && sudo apt-get autoremove -y && sudo apt-get autoclean -y && sudo apt-get update -y ; sudo apt-get upgrade -y && flatpak update -y; snap list|grep -v -E "Name|Nom" | while read Name Trash; do sudo snap refresh $Name; done && cleansnap && pip3 list | grep -v -E "Package|----"|awk "{print \$1}" | while read pkg; do pip3 install $pkg --upgrade --break-system-packages; done; rustup update; cargo install cargo-update; cargo install-update -a ; sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin'
alias getcomposer='curl -sS https://getcomposer.org/installer | php'
alias random='mktemp -u | cut -d'.' -f2'
alias freq='cut -f1 -d" " ~/.bash_history | sort | uniq -c | sort -nr | sed -r "s/\s{2,}//g" | head -n 50 | sort -n'
alias wifi='sudo iwlist wlan0 scan|grep -i ssid'
alias scanip='sudo nmap 192.168.1.0/24 -n -sP -PE -T5|grep report'
alias watch-network='sudo watch -n 1 -t lsof -P -i -n'
alias t='tmux attach || tmux'
alias diskinfo="sudo lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,STATE,GROUP,UUID,MODEL,VENDOR"
alias calendar='cal'
alias dip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'"
alias docker-update="docker image ls --filter "dangling=false" --format '{{.Repository}}:{{.Tag}}'|xargs -i docker pull {} && docker image prune"
alias gitfat='git rev-list --all --objects|sed -n $(git rev-list --objects --all|cut -f1 -d" "|git cat-file --batch-check|grep blob|sort -n -k 3|tail -n40|while read hash type size; do echo -n "-e s/$hash/$size/p "; done)|sort -n -k1;'
# alias gdiff="git diff --color | diff-so-fancy"
# alias git='LANG=en_US.UTF-8 git'
# alias debian='docker run -d --name debian -it debian > /dev/null 2>&1; docker exec -it debian bash'
# alias hacklab='docker run -d --name hacklab --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --net=host --privileged=true -v ~/Public:/mnt -it ston3o/docker-hacklab zsh > /dev/null 2>&1; docker start hacklab > /dev/null; docker exec -it hacklab zsh'
# alias rm='echo "This is not the command you are looking for."; false'
# alias yank='/usr/bin/yank -- xclip -selection c'
alias docker-clean="__clean() { docker volume ls -qf dangling=true | xargs -r docker volume rm; docker ps -aq -f status=exited | xargs -r docker rm -f; docker images --no-trunc | grep none | awk '{print $3 }' | xargs -r docker rmi }; __clean"
alias docker-clean-unused='docker system prune --all --force --volumes'
alias docker-clean-all='docker stop $(docker container ls -a -q) && docker system prune -a -f --volumes'
alias fake="curl -s https://randomuser.me/api/ | jq -r .results[0].login.username"
alias docker-clean-containers='docker container stop $(docker container ls -a -q) && docker container rm $(docker container ls -a -q)'
alias nexus='emulator -avd Nexus -gpu off'
# alias ip='ip --color'
# alias ipb='ip --color --brief'
alias full="df -P | awk '0+\$5 >= 80 {print}'"
alias gitfixmodes=gitfixalls
alias gitrefreshalls=gitrefresh
# alias code=vscodium
# alias eth="echo $(ip r|grep ^default | sort -k9 | head -1 | awk '{print $5}')"
alias lzd='lazydocker'
alias dust="dust -t 10"
alias diff='colordiff'
alias mount='mount |column -t'
#Get system memory, cpu usage, and gpu memory info quickly
## pass options to free ##
alias meminfo='free -m -l -t'
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
## Get server cpu info ##
alias cpuinfo='lscpu'
## older system use /proc/cpuinfo ##
##alias cpuinfo='less /proc/cpuinfo' ##
## get GPU ram on desktop / laptop##
alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'
## List the tasks using the most CPU time
alias hogs='ps uxga | sort --key=4.1 -n'
alias curlv='curl -w "@curl-format.txt" -o /dev/null -s '
alias gcurl='curl --header "Authorization: Bearer $(gcloud auth print-identity-token)"'
# alias bat=batcat
alias battery='upower -i /org/freedesktop/UPower/devices/battery_BAT1| grep -E "state|to\ full|percentage"'
gitfixalls() {
git diff --summary | grep --color 'mode change 100755 => 100644' | cut -d' ' -f7- | xargs -d'\n' chmod +x 2>/dev/null
git diff --summary | grep --color 'mode change 100644 => 100755' | cut -d' ' -f7- | xargs -d'\n' chmod -x 2>/dev/null
}
gitrefresh() {
cd ~/ownCloudPerso/Téléchargements/git
for dir in $(ls -1)
do
echo "== ${dir} =="
cd ~/ownCloudPerso/Téléchargements/git/${dir}
gitfixalls
gl
done
}
monitor() { watch -n1 -t "lsof -i -n|awk '{print \$1, \$2, \$9}'|column -t"; }
gi() { curl "https://www.gitignore.io/api/$@"; }
youtube-dl-mp3(){ youtube-dl $1 --extract-audio --audio-format mp3 }
streamer() { youtube-dl -o - "$1" | mpv - }
downloadAllDocument(){ wget --no-check-certificate -H -r -l 1 -nd -A "$2" "$1"; }
downloadAllImages(){ wget --no-check-certificate -nd -H -p -A jpg,jpeg,png,gif -e robots=off "$1"; }
dlmp3(){ wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off "$1"; }
detach() { sudo umount "/dev/"$1"1"; udisks --detach "/dev/$1"; }
debug() { sudo strace -Ff -tt -p $(pidof $1) 2>&1 | tee strace-$1.log; }
dockerrm() { docker rm $(docker ps -q -a); }
cleansnap() {
snap list --all | grep désactivé | while read Nom Version Révision Suivi Développeur Notes
do
sudo snap remove $Nom --revision $Révision
done
}
live() {
qemu-img create -f raw live 8G
qemu-system-x86_64 -enable-kvm -cpu host -m 4096 -drive file=live,format=raw -cdrom "$1"
rm live
}
tunnel(){
if [ -z "$1" ]; then
echo "Usage: tunnel [addr]"
else
pgrep obfsproxy > /dev/null 2>&1
if [ "$?" != 0 ]; then
echo "Start obfsproxy"
obfsproxy obfs2 --dest=${$1}:8080 client 127.0.0.1:9090 &
sleep 4
fi
echo "Start connexion tunnel"
ssh tunnel -D 127.0.0.1:7171
fi
}
stopwatch(){
date1=`date +%s`;
while true; do
echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
sleep 0.1
done
}
genssl(){
if [ -z "$1" ]; then
echo "usage: genssl [domain]"
else
openssl genrsa -out $1.key 1024
openssl req -new -key $1.key -out $1.csr
openssl x509 -req -days 365 -in $1.csr -signkey $1.key -out $1.crt
fi
}
passcli(){
# Prerequisite : secret-tool store --label=KeePass name keepass_password
# passcli locate entry
# passcli show entry
secret-tool lookup name keepass_password | /usr/bin/keepassxc-cli $(echo $1 | sed -e "s+show+show --show-protected+g") ~/Dropbox/Certificats/database.kdbx -k ~/Dropbox/keepass.key $2
}
treee(){
if [ which tree 2>/dev/null ]
then
tree
else
find . | sed '''s/[^/]*\//| /g;s/| *\([^| ]\)/+--- \1/'''
fi
}
whitespace() { sed -i 's/[[:space:]]*$//' $1 }
when() { zgrep -h " installed " /var/log/dpkg.log* | sort | grep $1 }
envof() { sed 's/\x0/\n/g' /proc/${1}/environ; }
gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}
master() {
if git rev-parse --git-dir > /dev/null 2>&1; then
git checkout master && git pull upstream master
else
hg pull && hg checkout "last(public())"
fi
}
procdump()
{
cat /proc/$1/maps | grep "rw-p" | awk '{print $1}' | ( IFS="-"
while read a b; do
sudo dd if=/proc/$1/mem bs=$( getconf PAGESIZE ) iflag=skip_bytes,count_bytes \
skip=$(( 0x$a )) count=$(( 0x$b - 0x$a )) of="$1_mem_$a.bin"
done )
}
ip_in_file()
{
file=$1
grep -E -o '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' ${file}
}
alias h='function hdi(){ howdoi $* -c -n 5; }; hdi'