Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 748 Bytes

README.md

File metadata and controls

31 lines (22 loc) · 748 Bytes

lscolors

CI

A zig library for colorizing paths according to the LS_COLORS environment variable. Designed to work with Zig 0.13.0.

Quick Example

const std = @import("std");

const LsColors = @import("lscolors").LsColors;

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();
    const allocator = gpa.allocator();

    var lsc = try LsColors.fromEnv(allocator);
    defer lsc.deinit();

    var dir = try std.fs.cwd().openIterableDir(".", .{});
    defer dir.close();

    var iterator = dir.iterate();
    while (try iterator.next()) |itm| {
        std.log.info("{}", .{try lsc.styled(itm.name)});
    }
}