1 unstable release
new 0.1.0 | Sep 9, 2024 |
---|
#357 in Filesystem
162 downloads per month
Used in see-cat
200KB
9K
SLoC
π¦ devicons
devicons
is a Rust library inspired by vim-devicons, providing functionality to retrieve 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
Add this to your Cargo.toml
:
[dependencies]
devicons = "0.1.0"
Usage
Hereβs a simple example of how to use devicons
to retrieve a file icon with the dark theme:
use std::path::Path;
use your_library::{File, Theme, icon_for_file};
fn main() {
let path = Path::new("example.txt");
let file = File::new(path);
let icon = icon_for_file(&file, Some(Theme::Dark));
println!("File: {}", file.name);
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:
cargo run --example <example_name>
License
This project is licensed under the UNLICENSE license.
Dependencies
~10KB