Quick Setup/change Swap file:
# swapfile
swap-activate() {
echo "How much MB should your swapfile have?"
echo "Enter here: "
read -r i
while ! [[ "$i" =~ ^[0-9]+$ ]]; do
echo "memory size, has to be numbers"
echo "try again: "
read -r i
done
echo -e 'Do you want to use \e[38;2;242;29;0m'"${i}"'\e[0mMB?'
echo "Press y are Enter to continue"
read -r r
if [[ "$r" =~ ^[Yy]$ ]] || [[ "$r" == "" ]]; then
sudo swapoff /swapfile &&
sh -c "sudo rm /swapfile" &&
sudo dd if=/dev/zero of=/swapfile bs=1M count="$i" status=progress &&
sh -c "sudo chmod 600 /swapfile" &&
sudo mkswap /swapfile &&
sudo swapon /swapfile &&
cat <<'EOF' >/etc/sysctl.d/99-swappiness.conf
vm.swappiness=6
vm.vfs_cache_pressure=66
vm.dirty_ratio=3
# sudo sysctl vm.vfs_cache_pressure=100
# sudo sysctl vm.swappiness=8
# sudo mkinitcpio -P
EOF
if sh -c "sudo grep -q '/swapfile' /etc/fstab"; then
sudo echo "Entry already exists in /etc/fstab"
else
echo "/swapfile none swap defaults 0 0" >>/etc/fstab
sudo echo "Entry added to /etc/fstab"
fi
else
echo "swapfile cancelled.."
fi
}
alias swap_delete='sudo swapoff /swapfile ; sudo rm /swapfile ; sudo mkinitcpio -P'
alias swapStatus='swapon --show'
A few cherry picks. If you have ideas to improve some of the more complex ones, let me know please. Especially on how to add flatpak
to check for updates.
System maintenance:
alias update='yay --answerupgrade none && flatpak uninstall --unused && flatpak update && rustup update && balooctl check'
alias uninstall='yay -Rs'
alias check='checkupdates ; yay -Qua ; rustup check'
alias clean='paccache -r && journalctl --vacuum-time=4weeks'
alias mirrors='reflector --protocol https --verbose --latest 25 --sort rate --save /etc/pacman.d/mirrorlist && eos-rankmirrors --verbose && yay -Syyu'
Neofetch alternative:
alias f='fastfetch --logo none --gpu-format '\''{2} [{6}] {3}'\'' --gpu-force-vulkan'
Note on fastfetch
: I have AMD GPUs and I want to have the driver versions displayed too. But with default configuration its not working correctly, just displaying mesa
for both GPUs. This ensures to add and display the Mesa version correctly, with a few additional information. And BTW who need these āuselessā logos anyway (they are always in my way when trying to copy a line or more importantly, when trying to grep).
Saving only a few keystrokes, but saving lot of lifes:
alias ..='cd .. && pwd'
alias brc='nvim ~/.bashrc'
alias ls='eza'
alias deck='ssh deck@steamdeck'
alias vim='nvim'
alias nrc='nvim ~/.config/nvim'
alias x='chmod +x'
Note about the brc
and nrc
: I usually have multiple of these with a leading letter (such as b
) representing a program name and always adding rc
to it, indicating its a configuration file. So regardless of the actual filename and format, its always āformattedā like this for consistency.
And a function:
mkcd() {
mkdir -- "${@}" && cd -- "${1}" || exit
pwd
}