https://github.com/alexpasmantier/rust-devicons
A Rust library that provides filetype glyphs (icons) for a wide range of common file formats.
https://github.com/alexpasmantier/rust-devicons
cli devicons filetype glyphs icons nerd-fonts rust rust-crate
Last synced: 3 months ago
JSON representation
A Rust library that provides filetype glyphs (icons) for a wide range of common file formats.
- Host: GitHub
- URL: https://github.com/alexpasmantier/rust-devicons
- Owner: alexpasmantier
- License: apache-2.0
- Created: 2024-09-09T12:13:00.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-12-28T23:20:56.000Z (7 months ago)
- Last Synced: 2025-04-09T16:05:21.447Z (3 months ago)
- Topics: cli, devicons, filetype, glyphs, icons, nerd-fonts, rust, rust-crate
- Language: Rust
- Homepage: https://crates.io/crates/devicons
- Size: 61.5 KB
- Stars: 30
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README





# π¦ `rust-devicons`
A Rust library inspired by [vim-devicons](https://github.com/ryanoasis/vim-devicons), that provides filetype glyphs (icons) for a wide range of common file formats.
## Features
- π¦ **Icon Retrieval**: Get file or directory icons based on file name/extension.
- π¦ **Icon Color**: Retrieve the color associated with the icon depending on the specified theme.
- π¦ **Filetype Support**: Supports a wide range of filetypes and filename conventions (dockerfile, makefile, etc.).
- π¦ **Customizable Themes**: Supports both light and dark themes.
## Installation
```sh
cargo add devicons
```_**NOTE**: you'll need to use a [NerdFont](https://www.nerdfonts.com/) to properly display the icons._
## Usage
Hereβs a simple example of how to use `devicons` to retrieve a file icon with the dark theme:
```rust
use std::path::Path;
use devicons::{File, Theme, icon_for_file, FileIcon};fn main() {
// getting the icon from a path with a specified theme
let path = Path::new("Cargo.toml");
let icon = icon_for_file(path, Some(Theme::Dark));// getting the icon from a string with a specified theme
let icon = icon_for_file("Cargo.toml", Some(Theme::Dark));// getting the icon from a path with the default theme
let icon = FileIcon::from(path);// directly getting an icon from a filename
let icon = FileIcon::from("Cargo.toml");println!("File: {}", path.to_string_lossy());
println!("Icon: {}", icon.icon);
println!("Color: {}", icon.color);
}
```### Running the Examples
You can find more usage examples in the `examples` directory. To run them, use:
```bash
cargo run --example
```## License
This project is licensed under the [Apache 2.0 License](LICENSE).