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.
tmp=$(flatpak list --app --columns=application | xargs echo -n) && echo -e '#!/bin/bash'"\nflatpak install "$tmp > install_flatpaks.sh && sudo chmod +x install_flatpaks.sh
Thanks for the command. I tried to "improve it" so that it automatically creates the shell script. This is my second time scripting so please don't sue me for ugly code.