I was switching to a new computer today and wanted to install all the flatpaks on my old one, without having to do anything manually of course
It turned out to be pretty easy, but I didn't find any obvious guide on the internet, so I figured I would document my solution
At first I tried the command:
flatpak list --app --columns=application > installed_flatpaks.txt
This will give you a list of only the application ID's, but each will be on a newline
The issue is that each ID is on its own line. To fix this, I added a second part to the command:
flatpak list --app --columns=application | xargs echo -n > installed_flatpaks.txt
The last step if you want to turn this into a script is to edit the file and add "flatpak install" in front of all the package names. You can then rename it e.g. "install_flatpaks.sh" and then run it on the new system with sh install_flatpaks.sh
I used a text editor to prepend this, but alternatively, there might be a way to prepend "flatpak install" using the CLI, but I'm not aware of any that's less complicated than just using a text editor.
You can also do this:
flatpak list --app --columns=origin --columns=application | awk '{print "flatpak install " $1,$2 " -y"}' > ~/flatpaks.sh