How can I get better output from "flatpak list"?

When I’m searching for a flatpak package in the CLI, lots of times the package name is truncated. No matter how wide I make the terminal, some package names are not shown in full. Without out that it’s hard to install the package.

In the screenshot two out of the four results are cut off because one flatpak has a really long description. Can this output get any better?

This will get you started. Let me know if you need to have this fleshed out.

flatpak search discord | awk '{ print $1  }' 

This gets the entire line w/o pretty formatting:

flatpak search discord | awk '{ print $0  }' 

Actually, the Field Separator is a tab so this might work better for you by putting the longer length of the description on a second line under the first line that contains name – package – version:

flatpak search discord | awk -F"\t" '{ print $1 " -- " $3 " -- " $4 "\n\t" $2 }'
2 Likes

Flatpak actually has options to display specific columns, so no additional filtering should be needed. Look for options with flatpak list --help. Also combine the output with more, so the lines are forced to be long and not shortened by “…”. Or better yet, replace first tab with a colon.

$ flatpak search discord --columns=name,description | sed 's/\t/: /'
Discord: Messaging, Voice, and Video Client
Veloren: Veloren is a multiplayer voxel RPG written in Rust. It is inspired by games such as Cube World, Legend of Zelda: Breath of the Wild, Dwarf Fortress and Minecraft.
Airshipper: Airshipper is the official launcher for Veloren.
Guilded: Messaging, Voice, and Video Client
1 Like

Ah, this is perfect. I’m embarrassed that I did not find this myself. Really what I was looking for was the application ID, not it’s name or description. I did not describe that very well originally. Making this a bash alias for sure flatpak search --columns=name:f,application:f,description:e

That gives me all the output I need.

I just have to say this is such a classic @MarkofCain answer. Like, how do you say your a Linux wizard without saying your a Linux wizard? I am partial to anything with the initials for Kernighan though.

3 Likes

Kudos to you @AiFromTheFuture for finding this or knowing where it was. I learned something here – the man page may not be enough. I hit ‘man flatpak’ and searched for “column” – not one reference. But there it was with your approach. I had always thought that the man page was the be-all and end-all. I stand corrected.

It is the opposite for me, I often forget to check the manual and only look at help options. BTW sometimes -h is a shorter help page with summary and --help a different longer output. I think this is very uncommon and not applicable to flatpak though, but a nice touch and idea IMHO.

The flatpak manual page is only a summary of all separate manual pages. You have to lookup the specific page for the specific sub command man flatpak-list.