237 lines
6.9 KiB
Bash
237 lines
6.9 KiB
Bash
#!/bin/sh
|
|
|
|
export EDITOR=nvim
|
|
## Grupa
|
|
|
|
aliasy () # Aliasy z opisem
|
|
{
|
|
awk 'match($0, /^## (.*)/, a) {print "\n", a[1], "\n"}; match($0, /^alias ([^=]*)=.*?[#](.*)/, a) {print a[1], "-", a[2]}; match($0, /([^\(]*)\(\).*?[#](.*)/, a) {print a[1], "-", a[2]}' $HOME/.aliases
|
|
}
|
|
|
|
alias sudo='sudo '
|
|
alias rr="ranger"
|
|
#alias man="firejail man"
|
|
alias df='df -H -x "squashfs"'
|
|
alias du='du -ch'
|
|
alias lt='ls --human-readable --size -1 -S --classify'
|
|
alias cp='cp -iv'
|
|
alias cpv='rsync -a --progress'
|
|
alias mv='mv -iv'
|
|
alias rm='rm -v'
|
|
#alias cat='bat'
|
|
alias ll='exa -l -g' # Lista plików
|
|
|
|
kate() {
|
|
nohup kate $1 >/dev/null 2>&1 &
|
|
}
|
|
|
|
aptUpgrade() {
|
|
sudo apt update --option Acquire::Retries=100 --option Acquire::http::Timeout="60"
|
|
|
|
sudo apt -y upgrade --option Acquire::Retries=100 --option Acquire::http::Timeout="60"
|
|
sudo apt --purge -y autoremove
|
|
sudo apt clean
|
|
sudo flatpak update -y
|
|
|
|
# set -x
|
|
# sudo systemctl unmask snapd.service
|
|
# sudo systemctl start snapd.service
|
|
# sudo systemctl status --no-pager snapd.service
|
|
# sudo snap refresh
|
|
# sudo kill -9 $(pgrep snapd)
|
|
# sudo systemctl stop snapd.service
|
|
# sudo systemctl mask snapd.service
|
|
}
|
|
|
|
## System
|
|
|
|
xu() { # Aktualizacja void-a
|
|
xi -u
|
|
sudo xbps-remove -oO
|
|
sudo flatpak -y update
|
|
sudo flatpak uninstall --unused
|
|
sudo vkpurge rm all
|
|
echo
|
|
echo "Do restartu"
|
|
echo
|
|
xcheckrestart
|
|
}
|
|
|
|
#alias xnc="export FZF_DEFAULT_OPTS='--extended' && xbps-query -Rs '' | sort -u | grep -v '*' | fzf --preview-window='bottom:45%:wrap' --preview 'xbps-query -Rv {2} '"
|
|
alias xfzf="export FZF_DEFAULT_OPTS='--extended' && xbps-query -Rs '' | sort -u | fzf --preview-window='bottom:45%:wrap' --preview 'xbps-query -Rv {2} '" # Lista pakietów
|
|
|
|
alias flatls='flatpak --columns=app,name,size,installation list' # Lista zainstalowanych flatpak-ów
|
|
|
|
removeOldSnaps() {
|
|
sudo snap list --all | awk '/disabled/{print $1, $3}' |
|
|
while read snapname revision; do
|
|
sudo snap remove "$snapname" --revision="$revision"
|
|
done
|
|
sudo find /var/lib/snapd/cache -maxdepth 1 -type f -name "*" -print0 | sudo xargs rm
|
|
}
|
|
|
|
alias lspart='sudo lsblk -o name,mountpoint,tran,fstype,label,size'
|
|
alias rsyncall='sudo rsync -a --info=progress2'
|
|
|
|
alias psMem='sudo /usr/bin/ps_mem -S' # Użycie pamięci
|
|
|
|
alias iotop='sudo iotop'
|
|
|
|
tarxz() {
|
|
tar -cvjf $1.tar.xz $1
|
|
}
|
|
|
|
## Sieć
|
|
#
|
|
alias mtr='mtr -b' # Lepszy ping
|
|
alias mtr8='mtr -b 8.8.8.8' # Ping 8.8.8.8
|
|
alias nmapScan='sudo nmap -sV -p 22,53,110,143,4564'
|
|
alias myip='curl ipinfo.io/ip' # Moje ip
|
|
|
|
alias networkStat="ssh -t netgear 'sudo iftop -i br-lan'" # Połączenia internetowe na routerze
|
|
alias nethogs="sudo nethogs" # Użycie sieci przez programy
|
|
|
|
alias typeClipboard='xclip -selection clipboard -out | tr \\n \\r | xdotool selectwindow windowfocus type --clearmodifiers --delay 25 --window %@ --file -'
|
|
|
|
## Docker
|
|
|
|
alias dock='sudo docker' # Docker
|
|
alias dockCompose='sudo docker-compose'
|
|
alias dockPs='sudo docker ps'
|
|
alias dockNet='sudo docker network'
|
|
alias dockCon='sudo docker container'
|
|
alias dockImg='sudo docker image'
|
|
|
|
## Virtualne maszyny
|
|
alias vmls='sudo virsh list --all'
|
|
alias vmblk='sudo virsh domblklist'
|
|
|
|
## Zfs
|
|
# zfs list -t snapshot -o name -S creation bpool/BOOT/ubuntu_6t3qt6 | tac | tail -n +5 | sudo xargs -n 1 zfs destroy -vr
|
|
# zfs list -t snapshot -o name -S creation rpool/ROOT/ubuntu_6t3qt6 | tac | tail -n +5 | sudo xargs -n 1 zfs destroy -vr
|
|
|
|
alias zfls="zfs list -o name,compressratio,compression,used,mountpoint " # Lista datasetów
|
|
alias zfVirt="zfs list -o name,compressratio,compression,used,mountpoint | rg 'data/USERDATA/ali0/virt' " # Maszyny virtualne
|
|
alias zfEmu="zfs list -o name,compressratio,compression,used,mountpoint | rg 'data/USERDATA/ali0/emu' " # Emulatory
|
|
alias zfSnap="zfs list -t snapshot -o name,mountpoint,used" # Snapshoty
|
|
|
|
## Pliki
|
|
|
|
function lsdu() (
|
|
export SEARCH_PATH=$*
|
|
if [ ! -e "$SEARCH_PATH" ]; then
|
|
echo "ERROR: Invalid file or directory ($SEARCH_PATH)"
|
|
return 1
|
|
fi
|
|
find "$SEARCH_PATH" -ls | gawk --lint --posix '
|
|
BEGIN {
|
|
split("B KB MB GB TB PB",type)
|
|
ls=hls=du=hdu=0;
|
|
out_fmt="Path: %s \n Total Size: %.2f %s \n Disk Usage: %.2f %s \n Compress Ratio: %.4f \n"
|
|
}
|
|
NF >= 7 {
|
|
ls += $7
|
|
du += $2
|
|
}
|
|
END {
|
|
du *= 1024
|
|
for(i=5; hls<1; i--) hls = ls / (2^(10*i))
|
|
for(j=5; hdu<1; j--) hdu = du / (2^(10*j))
|
|
printf out_fmt, ENVIRON["SEARCH_PATH"], hls, type[i+2], hdu, type[j+2], ls/du
|
|
}
|
|
'
|
|
)
|
|
|
|
alias kodiLast="cat ~/.kodi/temp/kodi.log | grep VideoPlayer::OpenFile | sed -nE 's/.*?VideoPlayer::OpenFile: (http.*?$)/\1/p' | tail -n1"
|
|
|
|
|
|
alias youtube-mp3="yt-dlp -x --audio-format mp3"
|
|
|
|
nnp()
|
|
{
|
|
# Block nesting of nnn in subshells
|
|
if [ -n "$NNNLVL" ] && [ "${NNNLVL:-0}" -ge 1 ]; then
|
|
echo "nnn is already running"
|
|
return
|
|
fi
|
|
|
|
# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
|
|
# If NNN_TMPFILE is set to a custom path, it must be exported for nnn to see.
|
|
# To cd on quit only on ^G, remove the "export" and set NNN_TMPFILE *exactly* as this:
|
|
# NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
|
|
export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
|
|
|
|
# This will create a fifo where all nnn selections will be written to
|
|
NNN_FIFO="$(mktemp --suffix=-nnn -u)"
|
|
export NNN_FIFO
|
|
(umask 077; mkfifo "$NNN_FIFO")
|
|
|
|
# Preview command
|
|
preview_cmd="/path/to/preview_cmd.sh"
|
|
|
|
# Use `tmux` split as preview
|
|
if [ -e "${TMUX%%,*}" ]; then
|
|
tmux split-window -e "NNN_FIFO=$NNN_FIFO" -dh "$preview_cmd"
|
|
|
|
# Use `xterm` as a preview window
|
|
elif (which xterm &> /dev/null); then
|
|
xterm -e "$preview_cmd" &
|
|
|
|
# Unable to find a program to use as a preview window
|
|
else
|
|
echo "unable to open preview, please install tmux or xterm"
|
|
fi
|
|
|
|
nnn "$@"
|
|
|
|
rm -f "$NNN_FIFO"
|
|
}
|
|
|
|
alias nnn='nnn -de' # NNN file manager
|
|
alias lf='lfub' # LF file manager
|
|
#-----
|
|
export LC_COLLATE="C" # hidden files on top
|
|
#-----
|
|
n () # to cd on quit
|
|
{
|
|
if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
|
|
echo "nnn is already running"
|
|
return
|
|
fi
|
|
export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
|
|
nnn "$@"
|
|
if [ -f "$NNN_TMPFILE" ]; then
|
|
. "$NNN_TMPFILE"
|
|
rm -f "$NNN_TMPFILE" > /dev/null
|
|
fi
|
|
}
|
|
|
|
|
|
alias grubUpdate="export ZPOOL_VDEV_NAME_PATH=YES && sudo -E bash -c 'update-grub'"
|
|
## Info
|
|
ti () { # Notowania
|
|
ticker PLN=X
|
|
ticker BTC-USD
|
|
ticker BZ=F
|
|
}
|
|
|
|
## Android
|
|
alias adbWifi='adb kill-server && adb tcpip 5555' # Włącz adb poprzez wifi w telefonie
|
|
|
|
## Git
|
|
#
|
|
gitAll () { # Git add, commit, push
|
|
git add *
|
|
git commit -m "$1"
|
|
git push
|
|
}
|
|
|
|
gitClean () { # Git zmniejsza katalogi .git
|
|
git gc
|
|
git gc --aggresive
|
|
git prune
|
|
}
|
|
alias wget='wget -c --tries 250'
|
|
|
|
alias whyKilled="dmesg -T| grep -E -i -B100 'killed process'" # Pokazuje dlaczego ostatnio procesy zostały zabite
|