Skip to content

Instantly share code, notes, and snippets.

@johanmcos
Created October 15, 2020 16:53
Show Gist options
  • Save johanmcos/be7c235ef5deabd1d1d745e674b561a0 to your computer and use it in GitHub Desktop.
Save johanmcos/be7c235ef5deabd1d1d745e674b561a0 to your computer and use it in GitHub Desktop.
export import-able list of installed flatpaks

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.

@METhOphetamine
Copy link

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.

@Vovkiv
Copy link

Vovkiv commented May 27, 2023

You can also do this:
flatpak list --app --columns=origin --columns=application | awk '{print "flatpak install " $1,$2 " -y"}' > ~/flatpaks.sh

@METhOphetamine
Copy link

thanks, that looks much cleaner lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment