Rowobin/zterm
A terminal manipulation library written in Zig.
A single-file low-level terminal manipulation library for unix systems written in Zig. Built as a learning exercise.
If you find any bugs or other issues, please let me know. If you think there's features that I should add, suggestions and PRs are always appreciated!
Tested with zig 0.14.1
Tested with MacOs Terminal, Ghostty and Kitty
Because this is a single-file library, you can just add the file "zterm.zig" to your project. You can also use zig fetch
.
Add library as a dependency in build.zig.zon
file with the
following command:
zig fetch --save git+https://github.com/Rowobin/zterm
Add the following to thebuild.zig
file:
const zterm_dep = b.dependency("zterm", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zterm", zterm_dep.module("zterm"));
Now the library can be used:
const std = @import("std");
const zterm = @import("zterm");
pub fn main() void {
std.debug.print("{s}Hello World in red!\n", .{
zterm.color.fg(.red)
});
}
You can build any example with:
> zig build example_name
List of examples:
I got the idea to build this library from mibu.