summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.zig17
-rw-r--r--src/stat.zig17
2 files changed, 27 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig
index 26b54f1..6080a47 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -10,6 +10,8 @@ pub fn main() !void {
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const cpuq = try stat.getcput(allocator);
+ const shell = try stat.shellenv(allocator);
+ defer allocator.free(shell);
defer allocator.free(cpuq);
const kernel = try stat.getkernel(allocator);
defer allocator.free(kernel);
@@ -26,12 +28,13 @@ pub fn main() !void {
const trm = try stat.uptime(allocator);
defer allocator.free(trm);
const art = artd.logo;
- try stdout.print("{s} Ezfetch\n", .{art[0]});
- try stdout.print("{s} -----------------\n", .{art[1]});
- try stdout.print("{s} Os: {s}\n", .{ art[2], osd });
- try stdout.print("{s} User@hostname: {s}@{s}\n", .{ art[3], user, hst });
- try stdout.print("{s} Kernel: {s}\n", .{ art[4], kernel });
- try stdout.print("{s} Cpu: {s}\n", .{ art[5], cpuq });
- try stdout.print(" Ram: {s} / {s}\n", .{ ge, ram });
+ try stdout.print(" Ezfetch\n", .{});
+ try stdout.print("{s} -----------------\n", .{art[0]});
+ try stdout.print("{s} Os: {s}\n", .{ art[1], osd });
+ try stdout.print("{s} User@hostname: {s}@{s}\n", .{ art[2], user, hst });
+ try stdout.print("{s} Kernel: {s}\n", .{ art[3], kernel });
+ try stdout.print("{s} Cpu: {s}\n", .{ art[4], cpuq });
+ try stdout.print("{s} Ram: {s} / {s}\n", .{ art[5], ge, ram });
try stdout.print(" larptime: {s}\n", .{trm});
+ try stdout.print(" shell: {s}\n", .{shell});
}
diff --git a/src/stat.zig b/src/stat.zig
index 7edf52a..20a44e4 100644
--- a/src/stat.zig
+++ b/src/stat.zig
@@ -154,3 +154,20 @@ if (std.process.getEnvVarOwned(allocator, "USER")) |username| {
return std.fmt.allocPrint(allocator, "{d}s", .{s});
}
}
+ pub fn shellenv(allocator: std.mem.Allocator) ![]const u8 {
+ const shell = try std.process.getEnvVarOwned(allocator, "SHELL");
+ defer allocator.free(shell);
+ const pref = "/usr/bin/";
+ const preu = "/bin/";
+ if (std.mem.startsWith(u8, shell, pref)) {
+ const pren = shell[pref.len..];
+ const name_ = if (std.mem.indexOfScalar(u8, pren, ' ')) |space_idx| pren[0..space_idx] else pren;
+ return try allocator.dupe(u8, name_);
+ }
+ if (std.mem.startsWith(u8, shell, preu)) {
+ const pren = shell[preu.len..];
+ const name_ = if (std.mem.indexOfScalar(u8, pren, ' ')) |space_idx| pren[0..space_idx] else pren;
+ return try allocator.dupe(u8, name_);
+ }
+ return try allocator.dupe(u8, shell);
+ }