Zig package
Use zmx as a library in Zig projects
using zmx as a zig package #
The library in src/lib.zig is importable as the zmx package from other Zig projects. All functions take (alloc, io, ...) from std.process.Init.
1// build.zig.zon
2.dependencies = .{
3 .zmx = .{
4 .url = "git+https://github.com/neurosnap/zmx#<commit>",
5 .hash = "...",
6 },
7},
1// build.zig
2const zmx = b.dependency("zmx", .{ .target = target, .optimize = optimize });
3exe_mod.addImport("zmx", zmx.module("zmx"));
1// your source
2const zmx = @import("zmx");
3
4const exit_code = try zmx.run(gpa, io, "my-session", &.{"echo", "hi"}, .{});
5const sessions = try zmx.list(gpa, io);
6defer {
7 for (sessions) |s| s.deinit(gpa);
8 gpa.free(sessions);
9}
notes #
zmx.runcreates the session (and daemon) if it doesn't exist, no need to callzmx.createfirst.zmx.createis only available when the package is built with-Ddaemon=true(the default).- See
examples/for complete working programs.
<< PREV
SSH workflow
NEXT >>
Configuration & Debugging