From 0a77fbb4a1c69d5695eb3d03522798ee17b3fc8d Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 5 May 2025 08:15:32 -0500 Subject: [PATCH] icons: allow icons in short mode --- src/main.zig | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main.zig b/src/main.zig index 5bff931..c52d433 100644 --- a/src/main.zig +++ b/src/main.zig @@ -235,6 +235,19 @@ pub fn main() !void { fn printShort(cmd: Command, writer: anytype) !void { const colors = cmd.opts.colors; for (cmd.entries) |entry| { + if (cmd.opts.useIcons()) { + const icon = Icon.get(entry, cmd.opts); + + if (cmd.opts.useColor()) { + try writer.writeAll(icon.color); + try writer.writeAll(icon.icon); + try writer.writeAll(colors.reset); + } else { + try writer.writeAll(icon.icon); + } + + try writer.writeByte(' '); + } switch (entry.kind) { .directory => try writer.writeAll(colors.dir), .sym_link => try writer.writeAll(colors.symlink), @@ -315,7 +328,7 @@ fn printLong(cmd: Command, writer: anytype) !void { } if (cmd.opts.useIcons()) { - const icon = Icon.get(entry); + const icon = Icon.get(entry, cmd.opts); if (cmd.opts.useColor()) { try writer.writeAll(icon.color); @@ -743,7 +756,7 @@ const Icon = struct { .{ "zon", Icon.zig }, }); - fn get(entry: Entry) Icon { + fn get(entry: Entry, opts: Options) Icon { // 1. By name // 2. By extension // 3. By type @@ -767,7 +780,7 @@ const Icon = struct { }, .named_pipe => return pipe, .sym_link => { - if (posix.S.ISDIR(entry.statx.mode)) { + if (opts.long and posix.S.ISDIR(entry.statx.mode)) { return symlink_dir; } return symlink; -- 2.51.2