#!/bin/bash

# makelist creates a list of current packages, removes the second field (version numbers), and replaces all the new lines with spaces and then writes it to a file called my_packages.txt, you can more or less copy and paste this list into pacman -S to re-download all your files, useful if you need to start from scratch. Needs a script eventually to query aur_packages directory for packages downloaded directly from AUR and not Artix repositories.

pacman -Q | awk '!($2="")' | tr '\n' ' ' > my_pacman_packages.txt

pacman -Qm | awk '{ print $1 }' | tr '\n' ' ' > my_paru_packages.txt

find /usr/lib/node_modules -maxdepth 1 | sed -r 's/^\/usr\/lib\/node_modules\///g' | tr '\n' ' ' > my_npm_packages.txt

pip list | awk '{ print $1 }' | tr '\n' ' ' > my_pip_packages.txt

go list std | tr '\n' ' ' > my_go_packages.txt

find /usr/bin | sed -r 's/^\/usr\/bin\///g' | tr '\n' ' ' > my_binaries.txt

# currently empty...
# cargo install -- list > my_cargo_packages.txt

# for debian distributions:
# apt list --installed > my_packages.txt

# can be used in conjunction with xargs to reinstall all packages:
# cat my_packages.txt | sudo xargs pacman -S
