pls-rs / pls

`pls` is a prettier and powerful `ls(1)` for the pros.
https://pls.cli.rs/
GNU General Public License v3.0
837 stars 25 forks source link

Implement support for SVG/PNG icon sets #104

Open odebroqueville opened 3 months ago

odebroqueville commented 3 months ago

Problem

Right now the looks are a bit disappointing and there's no default config file to handle different common file types, like PDF, Word, Excel, JS, HTML, CSS, etc...

Description

I really like the Material Design icons used in VS Code. I feel it would make a big difference if we could have them in the terminal (I'm thinking Warp preferably or iTerm2).

Alternatives

I've tried exa which is now deprecated and has been replaced with eza. It has an --icons argument which displays icons next to files and folders. However, I find that it's not quite as polished as pls, especially the --long view. I'd be interested to know how they display the icons though. Are they just using a nerd font or is it something else?

Additional information

Warp is being actively developed, so maybe they could make changes so that SVG icons could be used in their terminal. However, I honestly don't know if this issue feasible, because I remember that terminals are text based.

P.S. On a side note, it would be nice to have a directory where users could share their config files (.pls.yml).

dhruvkb commented 3 months ago

You can find some common pls configuration examples in the docs page "Starter configs". I agree with your suggestion and will add a config for common file types in the same page.

So far the only universal way to display icons in the terminal is to use a Nerd Font. pls and many other tools that display pretty icons in the terminal (like exa, eza and Starship) all use Nerd Fonts to render the icons.

However pls, being customisable, allows you to use emoji instead of Nerd Fonts if you prefer those (by defining your own specs), and even turn icons off altogether with --icon=false if you don't want to set up a Nerd Font and play with the icons.

An SVG based icon pack would be very hard to support in the terminal because terminals are text-based and any approach that ends up supporting images inline with other text will not be be cross-terminal-app, let alone cross-platform.

I will gladly accept PRs that add more config examples to the aforementioned docs page. It would indeed be very nice for people to share .pls.yml with each other in the community.

odebroqueville commented 3 months ago

I think a terminal called broot supports SVG rendering from what I saw on Kitty's website. The folks at work are monitoring a feature request and posting infrequent updates on GitHub to support Kitty's image rendering protocol. You might want to keep an eye on this. In the past, I had created a .pls.yml file for common document and file types I use, but I screwed up and deleted my pls files by mistake. It would be awesome if you would progressively publish a .pls.yml supporting widespread file types so that you have something ready for the day Warp support graphics/icons.

dhruvkb commented 3 months ago

I've added a starter configuration for common files in the docs.

Additionally I will keep this issue open to consider how we can make use of Kitty image protocol to support higher quality icons in terminals where the protocol is implemented.

odebroqueville commented 2 months ago

@dhruvkb Hey Dhruv, Sorry for the late response. That's very kind of you. It looks really neat! Under common files, would you mind adding MS Office files (.xls, .doc, .ppt*) as well as common text files (.txt, .rtf) and table files (.csv, .tsv). Please also add Markdown files (.md) under Web Development maybe. I think that that really rounds up the most common file types we would use. I created the following file, which contains everything in one file:

pls.txt

P.S. I don't know why, but I couldn't upload the pls.yml file here (had to change the file extension to .txt)!

dhruvkb commented 2 months ago

I spent a lot of time today reading the Kitty graphics protocol spec to determine how we could support SVG icons in pls, and open the door to a massive library of SVG icon packs (like VS Code).

It is doable, in a manner similar to https://github.com/Canop/broot which can render SVGs, but it is a massive effort that I can only invest time into if there is popular demand for it.

odebroqueville commented 2 months ago

It would be amazing to have these icon sets available in the terminal. I think pls would quickly become the most popular directory listing command if the feature was available in the VS Code terminal and in Warp. I believe VS Code is the most popular dev editor nowadays and Warp is getting a lot of traction as well thanks to its AI. Warp may soon have support for Kitty, but I don't see any plans in that direction for VS Code's terminal. For pls to quickly become widely adopted, all it would take is an ad by VS Code (maybe in an update) or by the makers of the Material Design icons. Warp could do something similar. The two must cover very many devs out there.

UPDATE: maybe what would require less effort, is to assume that you're bringing pls to a terminal that already supports Kitty's Graphic Protocol, so that what remains is to change the .pls.yml template to accept (as rendered in HTML) or a path to an .svg file for the icon property. Not sure this makes sense because I know nothing about Kitty's Graphic Protocol!

dhruvkb commented 2 months ago

I have a prototype of this working in Python, and it looks amazing!

image

It is still a bit far off from landing in pls though, for these reasons:

I will still continue to hack on this, and PRs are welcome. Personally I find the icon collection in Nerd Fonts underwhelming and having this would be a massive UX improvement, once these hurdles have been overcome.

odebroqueville commented 2 months ago

Looks really nice! Are you running the above in Kitty or broot? I forked and updated the icons folder from the VS Code Material Design theme to contain an svg folder (for icons in svg format) and a png folder (for icons in png format each in 3 sizes: 16x16, 24x24 and 32x32). Ideally, the size of the icon displayed would depend on the font size used in the terminal. Can terminals cache image data? The way I would see this working is that pls would first test if Kitty's Graphic Protocol is supported. If it's the case, then get the terminal's font size and choose the icon size to be fetched accordingly. If not, then fallback on Nerd Font icons. Sorry I can't help you with the code, but I know nothing about Rust!

dhruvkb commented 2 months ago

This is https://github.com/wez/wezterm, it's a terminal emulator that's very customisable (very much like pls!) that also supports the Kitty graphics protocol. I used the icons from https://github.com/catppuccin/vscode-icons.

I'm using a lot of https://github.com/Canop/broot's code for inspiration and reference. In that field, it is nice that we have so many open-source CLI projects in Rust.