feat: add logic for username and hostname colors
This commit is contained in:
17
src/main.zig
17
src/main.zig
@@ -27,14 +27,15 @@ pub fn main() !void {
|
|||||||
|
|
||||||
const username = try detection.user.getUsername(allocator);
|
const username = try detection.user.getUsername(allocator);
|
||||||
const hostname = try detection.system.getHostname(allocator);
|
const hostname = try detection.system.getHostname(allocator);
|
||||||
try modules_list.append(try std.fmt.allocPrint(allocator, "{s}{s}{s}@{s}{s}{s}", .{
|
|
||||||
ascii.Yellow,
|
const username_hostname_color = if (config.getUsernameHostnameColor(conf)) |color| blk: {
|
||||||
username,
|
var buf: [32]u8 = undefined;
|
||||||
ascii.Reset,
|
const rgb = try ascii.hexColorToRgb(color);
|
||||||
ascii.Yellow,
|
const formatted_color = try std.fmt.bufPrint(&buf, "\x1b[38;2;{d};{d};{d}m", .{ rgb.r, rgb.g, rgb.b });
|
||||||
hostname,
|
break :blk formatted_color;
|
||||||
ascii.Reset,
|
} else ascii.Yellow;
|
||||||
}));
|
|
||||||
|
try modules_list.append(try formatters.getFormattedUsernameHostname(allocator, username_hostname_color, username, hostname));
|
||||||
allocator.free(hostname);
|
allocator.free(hostname);
|
||||||
allocator.free(username);
|
allocator.free(username);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user