-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bash_aliases.Linux
184 lines (174 loc) · 10.5 KB
/
.bash_aliases.Linux
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
# vim: ft=bash noet:
! declare 2>&1 | grep -wq ^colors= && [ $BASH_VERSINFO -ge 4 ] && source $initDir/.colors
test "$debug" -gt 0 && \echo "=> Running $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal ..."
lswiFiInterfaces() {
set -o pipefail
if \ls /sys/class/ieee80211/*/device/net 2>/dev/null;then
:
elif \ls -d /sys/class/net/*/wireless 2>/dev/null | awk -F/ '{print$5}';then
:
elif [ "$osFamily" = Android ];then
$getprop wifi.interface
fi | \egrep -v "p2p[0-9]"
set +o pipefail
}
export wiFiInterface=$(lswiFiInterfaces | head -1)
#alias lpr="\lpr -P ppti-14-503-imp -o PageSize=A4 -o PageRegion=A4 -o Resolution=default -o InputSlot=Tray2 -o Duplex=DuplexNoTumble -o PreFilter=No"
#alias lpr="\lpr -o PageSize=A4 -o PageRegion=A4 -o Resolution=default -o InputSlot=Tray2 -o Duplex=DuplexNoTumble -o PreFilter=No"
findExcludedPathList="./proc ./sys ./dev"
findPrunePathsExpression="( -type d -a ( -name .git $(printf -- " -o -path %s" $findExcludedPathList) ) ) -prune -o"
duExcludedPathList="./proc ./sys ./dev"
excludePathsDuExpression=$(printf -- "--exclude %s " $duExcludedPathList)
test "$wiFiInterface" && {
alias wifiSpeed="\iwlist $wiFiInterface bitrate;\iw dev $wiFiInterface link"
alias restartWifi=wifiRestart
}
type -P lspci >/dev/null && {
alias lspci="\lspci -nn"
alias lspciSimple="\lspci -nnvmk"
alias lspcimore="\lspci -m"
alias lsvideo="\lspci -nnd ::300"
alias lsaudioCards="\lspci -nnd ::403"
alias lssata='\lspci -nnd::0106'
alias lssas='\lspci -nnd::0107'
alias northBridge="\lspci -nns 0:0.0"
alias southBridge="\lspci -nnd ::601"
alias lsgpu=lsvideo
alias lsvga=lsvideo
alias lswifi='\lspci -nnd ::0280'
}
alias audioCardsMinimumInfo='pactl list sinks | egrep -e "^Sink |Ports?:|available"'
alias audioInfo="pactl info"
alias batteryINFO='upower -i $(upower -e 2>/dev/null | grep BAT) 2>/dev/null;acpi -i 2>/dev/null && echo;LC_ALL=C \inxi -z -Bxxx 2>/dev/null'
alias bluetoothInfo='\inxi -E'
alias bluetoothVersion=$'hciconfig -a | awk \'/^hci[0-9]:/{print$1} /Address:/{print"Address: "$3} /HCI [Vv]ersion/{print"Bluetooth Version: "$3" "$4}\''
alias catFiles="\tail -vn +1"
alias cdLabel="\blkid -o value -s LABEL /dev/cdrom"
#type -P ccze >/dev/null 2>&1 && alias ccze="\ccze -A" && alias dmesg="\ccze -A < /var/log/dmesg"
alias connect2eduroam="connect2SSID eduroam"
alias cp='\cp --preserve=timestamps -v'
#alias dmesg="\grc less /var/log/dmesg"
alias diskSizes='\lsblk -do NAME,SIZE'
alias dmesg="\dmesg -T"
alias dmesgErrors="dmesg -l err,crit,alert,emerg"
alias dmesgErrorsNWarings="dmesgErrors -l warn"
alias dnsInfo="( \nmcli -f IP4.DNS,IP6.DNS dev list iface $wiFiInterface || \nmcli -f IP4.DNS,IP6.DNS dev show) 2>/dev/null | grep DNS || egrep -v '^(#|\$)' /etc/resolv.conf"
alias dvdLabel="\blkid -o value -s LABEL /dev/dvd"
alias ethinfo='\ip -c -br link show'
alias findDeadLinks='$find . -xtype l -exec ls --color -l {} +'
alias findDirectoriesWithLotsOfInodes=$'locate "" | sed "s|/[^/]*$|/|g" | sort | uniq -c | sort -n | tee filesperdirectory.txt | tail'
alias firefoxDefrag='pgrep firefox || time find ~/.mozilla/firefox/ -name "*sqlite" -ls -exec sqlite3 -echo {} vacuum \;'
alias fsType="\lsblk -n -o FSTYPE"
alias gpuRAM='\dmesg | grep VRAM'
alias hardwareUNCLAIMED='sudo \lshw | sed -n "/UNCLAIMED/,/configuration:/ p"'
alias ipAddress=$'\ip -4 -o a | awk -F " *|/" \'!/lo\s/{print$4;exit}\''
alias ipbrief="\ip -brief" # Since iproute2 v4.3
alias ipinfo='\ip -c -br addr show'
alias ipmcastinfo='\ip -c -br maddr show'
alias isEFI=isUEFI
alias isUEFI="[ -d /sys/firmware/efi ] && echo 'Session EFI' || echo 'Session non-EFI'"
alias isVM='egrep -i "vmware|virtal" /sys/class/dmi/id/sys_vendor /sys/class/dmi/id/product_name -q && echo true || echo false'
alias isWayLand=$'printf "$XDG_SESSION_TYPE => ";loginctl show-session $(loginctl | awk "/$USER/"\'{print $1}\') -p Type | grep =wayland -q && echo true || echo false'
alias journalSvc="journalctl --unit"
alias journalctl='\journalctl -e'
alias journalctlErrors='\journalctl -p err..emerg --no-pager'
alias kwinRestart="\kwin --replace >/dev/null 2>&1 &"
alias l="ls --color"
alias lastme='last -w $USER'
alias lastmeToday='lastme | \egrep -e "$(LC_TIME=C date +%b\ %_d)"'
alias ll="ls -blF --time-style=+'%Y-%m-%d %T'"
alias llk="ll --block-size=K"
alias llm="ll --block-size=M"
alias ls="ls --color -F"
alias lsinterfaces="\ls /sys/class/net"
alias lsprocessors="lscpu -J | jq -r '.lscpu | map( select(.field | IN(\"CPU(s):\",\"Model name:\") ).data ) | join(\" x \")'"
alias lstpm='test -s /proc/tpminfo && cat /proc/tpminfo;lsmod | grep tpm;\ls /dev/tpm? /dev/tpmrm? 2>/dev/null && \ls -ld /sys/kernel/security/tpm?/ /sys/class/tpm/tpm?/device/caps /sys/class/tpm/tpm?/tpm_version_major /sys/class/tpm/tpm?/device/firmware_node/description;\ls /dev/tpm? /dev/tpmrm? 2>/dev/null && sudo dmidecode -t 43'
alias lszombies='\ps aux | grep -v grep | grep defunct'
alias lxterm="\lxterm -sb -fn 9x15"
alias macinfo='\ip -c -br link show'
alias mmcSize="awk '/[0-9]/{print FILENAME\": \"\$1/(2*1024^2)\" GiB\"}' /sys/class/block/mmcblk?/size"
alias mmcInfo="tail -vn +1 /sys/class/block/mmcblk0/device/driver/mmc*/uevent"
alias mount="mount -v"
alias netstatLSOF="\lsof +c 12 -i -P"
alias nmStatus="\service network-manager status"
alias odtinfo=odfInfo
alias osID="awk -F= '/^ID=/{print\$2}' /etc/os-release"
alias osID_LIKE="awk -F= '/^ID_LIKE=/{print\$2}' /etc/os-release"
alias osVersion=version
alias pip_pypy="\pypy -m pip"
alias pip_pypy3="\pypy3 -m pip"
alias Pgrep="grep -P"
alias pulseaudioServiceRestart="systemctl --user restart pulseaudio.socket"
alias qtVersion='QT_SELECT=$(qtchooser -l | tail -1) qmake -v'
alias quota="\quota -s"
alias ramSize=$'\\awk \'BEGIN{split("B kB MB GB TB PB EB", unit)}/MemTotal:/{size=$2*1024;exponent=int( log(size)/(3*log(10)) );print size/10^(3*exponent)" "unit[exponent+1]}\' /proc/meminfo'
alias ramSize2='\bc -l <<< $(getconf _PHYS_PAGES)*$(getconf PAGE_SIZE) | 2si'
alias rename="\prename -v"
alias rename2LowerCase="\prename -v y/A-Z/a-z/"
alias rename2UpperCase="\prename -v y/a-z/A-Z/"
alias rgrep=$'rg -uu -g !.git/'
alias rgrepFollowSymLinks="rgrep -L"
alias rmdir="\rmdir -v"
alias rsync='time \rsync -uth -P -z --skip-compress=$RSYNC_SKIP_COMPRESS_LIST $RSYNC_EXCLUSION'
alias scp='time \rsync -h --progress -u -zt --skip-compress=$RSYNC_SKIP_COMPRESS_LIST $RSYNC_EXCLUSION'
#alias sed="\sed -r" # La completion ssh ne fonctionne pas si l'alias est actif a cause du script /usr/share/bash-completion/bash_completion qui est obsolete, faire une maj du package bash_completion vers la v2.8
alias showWM='cat /etc/X11/default-display-manager | \xargs basename'
#alias halt="\systemctl halt && exit"
alias poweroff="\systemctl poweroff && exit"
alias reboot="\systemctl reboot;exit"
alias startSvc="\systemctl start"
alias statusSvc="\systemctl status"
alias stopSvc="\systemctl stop"
alias suspend="\systemctl suspend;exit"
alias swapUsage='smem -t -s swap -k'
alias swappiness='echo "$(cat /proc/sys/vm/swappiness)%"'
alias sysInfo='paste -d" " /sys/class/dmi/id/sys_vendor /sys/class/dmi/id/product_name'
#alias topf5=$'$find . -xdev $findPrunePathsExpression -type f -size +10M -exec ls -l --block-size=M --time-style=+"%Y-%m-%d %T" {} \; 2>/dev/null | sort -nrk5 | head -5 | awk \'{total+=$5;print}END{print"=> total = "total" MiB"}\''
alias totalLVSize=$'awk \'/LV_/{sub("g$","",$4);total+=$4}END{print"=> Total = "total}\''
alias topf10='$find . -xdev $findPrunePathsExpression -type f -size +10M -exec ls -l --block-size=M --time-style=+"%Y-%m-%d %T" {} \; 2>/dev/null | sort -nrk5 | head -10 | numfmt --field 5 --from=iec --to=iec-i --suffix=B'
alias topf50='$find . -xdev $findPrunePathsExpression -type f -size +10M -exec ls -l --block-size=M --time-style=+"%Y-%m-%d %T" {} \; 2>/dev/null | sort -nrk5 | head -50 | numfmt --field 5 --from=iec --to=iec-i --suffix=B'
alias topf5='$find . -xdev $findPrunePathsExpression -type f -size +10M -exec ls -l --block-size=M --time-style=+"%Y-%m-%d %T" {} \; 2>/dev/null | sort -nrk5 | head -5 | numfmt --field 5 --from=iec --to=iec-i --suffix=B'
alias icmptraceroute="traceroute.db -I"
alias tcptraceroute="tcptraceroute.db"
alias udptraceroute="traceroute.db -U"
alias umount="umount -v"
alias version="\lsb_release -sd"
alias wifimac="mac@ $wiFiInterface"
alias wifiDriversUsed=$'\lsmod | awk \'/cfg80211/{print$NF}\''
alias windowManager=showWM
alias wlanmac=wifimac
alias xdg-dirs='ls $HOME/.config/user-dirs.dirs && grep ^XDG $HOME/.config/user-dirs.dirs'
alias ytdlInstall="pip3 install youtube-dl || pip install youtube-dl"
if groups $USER 2>/dev/null | \egrep -wq "sudo|admin|adm|root|wheel"
then
test -r $initDir/.bash_aliases.$osID_LIKE && Source $initDir/.bash_aliases.$osID_LIKE # Si c'est un Linux de type Debian ou Redhat
alias bluetoothRestart="sudo service bluetooth stop;sleep 1;sudo service bluetooth start;service bluetooth status"
alias checkSudoFile="\visudo -cf"
alias cupsRestart="sudo service cups restart;service cups status || sudo service cups status"
alias dosfsck="\dosfsck -r"
alias fdiskListALLDisks="\fdisk -l $(\ls /dev/sd{a..z} /dev/mmcblk{0..9} 2>/dev/null)"
alias goSudo="\sudo -E go"
alias grubFindUUID="\sudo grub-probe --target=compatibility_hint --device"
alias lvextend="\lvextend -r"
alias lvextendToFillVG="\lvextend -r -l +100%FREE"
alias lvreduce="\lvreduce -r"
alias lvresize="\lvresize -r"
alias pvs="\pvs -v"
alias pgrep="\pgrep -lf"
alias pip2Update="\sudo -H pip2 install -U pip || \sudo -H pip install U pip"
alias pip3Update="\sudo -H pip3 install -U pip || \sudo -H pip install -U pip"
alias restart_nm="nmRestart"
alias rtmpdumprd='\sudo iptables -t nat -A OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner root -j REDIRECT'
alias rtmpdumprs='\sudo iptables -t nat -D OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner root -j REDIRECT'
alias update-mime-database="\sudo \rm -vf /usr/share/mime/packages/kde.xml;time sudo \update-mime-database /usr/share/mime"
alias updatedb="time sudo updatedb"
alias updateCurrencies="sudo units_cur -v"
alias usermod="\usermod -a" # A default to always use with "usermod -G"
alias youtube-dlUpdate='\sudo -H pip3 install -U youtube-dl || \sudo -H pip install -U youtube-dl'
alias ytdlInstall='\sudo -H pip3 install youtube-dl || \sudo -H pip install youtube-dl'
alias vgs="\vgs -v"
else
alias updatedb='time updatedb -l 0 -o ~/.local/lib/mlocate/mlocate.db --prunefs "rpc_pipefs afs binfmt_misc proc smbfs iso9660 ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre tmpfs usbfs udf fuse.glusterfs fuse.sshfs curlftpfs"'
fi
set +x
test "$debug" -gt 0 && \echo "=> END of $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal"