zsh: add swapfile creation and deletion functions

This commit is contained in:
PowerUser64 2021-10-18 17:30:51 -07:00
parent cf7a24ab92
commit c260d0999c

17
.zshrc
View file

@ -119,6 +119,9 @@
dc='docker-compose' \ dc='docker-compose' \
occ='docker exec -it -u www-data nextcloud php occ' \ occ='docker exec -it -u www-data nextcloud php occ' \
# file copying with a progress bar
alias cpv="rsync -ah --info=progress2"
# lists all open ports, along with some other info # lists all open ports, along with some other info
alias ls-ports='netstat -tulpn' alias ls-ports='netstat -tulpn'
@ -375,6 +378,20 @@
echo $(($*)) echo $(($*))
} }
# Makes a swapfile at /swapfile of a given size (ex: mkswp 4G)
mkswp() {
sudo fallocate -l "$1" /swapfile &&
sudo chmod 600 /swapfile
sudo mkswap /swapfile &&
sudo swapon /swapfile
}
# Deletes the swapfile created by mkswp()
rmswp() {
sudo swapoff -v /swapfile &&
sudo rm /swapfile
}
# optionally source an external function file # optionally source an external function file
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/fnrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/fnrc" [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/fnrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/fnrc"
} }