set LESS_TERMCAP_X variables in mzteinit

This commit is contained in:
LordMZTE 2023-08-01 14:41:23 +02:00
parent a02d1ccdff
commit 64cb69dba5
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
4 changed files with 55 additions and 10 deletions

View file

@ -7,15 +7,6 @@ alias nv="nvim"
#alias nvide="rbg neovide --nofork --multigrid --"
alias nvide="rbg neovide --nofork --"
# colored man pages
set -gx LESS_TERMCAP_mb \e'[1;32m'
set -gx LESS_TERMCAP_md \e'[1;32m'
set -gx LESS_TERMCAP_me \e'[0m'
set -gx LESS_TERMCAP_se \e'[0m'
set -gx LESS_TERMCAP_so \e'[01;33m'
set -gx LESS_TERMCAP_ue \e'[0m'
set -gx LESS_TERMCAP_us \e'[1;4;31m'
function rbg
$argv &>/dev/null &
end

View file

@ -1,6 +1,8 @@
const std = @import("std");
const sysdaemon = @import("sysdaemon.zig");
const util = @import("util.zig");
const msg = @import("message.zig").msg;
const log = std.log.scoped(.env);
@ -52,6 +54,19 @@ pub fn populateEnvironment(env: *std.process.EnvMap) !bool {
// neovim
try env.put("EDITOR", "nvim");
// Colored manpages
{
inline for ([_][2][]const u8{
.{ "mb", "1;32m" },
.{ "md", "1;32m" },
.{ "me", "0m" },
.{ "se", "0m" },
.{ "so", "01;33m" },
.{ "ue", "0m" },
.{ "us", "1;4;31m" },
}) |kv| try env.put("LESS_TERMCAP_" ++ kv[0], "\x1b[" ++ kv[1]);
}
// Java options
{
var bufstream = std.io.fixedBufferStream(&buf);
@ -199,7 +214,7 @@ pub fn populateSysdaemonEnvironment(env: *const std.process.EnvMap) !void {
));
}
log.debug("sysdaemon env cmd: {s}", .{argv.items});
log.debug("sysdaemon env cmd: {}", .{util.fmtCommand(argv.items)});
var child = std.ChildProcess.init(argv.items, env.hash_map.allocator);
const term = try child.spawnAndWait();

View file

@ -1,3 +1,4 @@
const std = @import("std");
const at = @import("ansi-term");
pub const ansi_clear = "\x1b[2J\x1b[1;1H";
@ -8,3 +9,40 @@ pub inline fn updateStyle(writer: anytype, current: *?at.style.Style, new: at.st
try at.format.updateStyle(writer, new, current.*);
current.* = new;
}
fn formatCommand(
cmd: []const []const u8,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = options;
_ = fmt;
var first = true;
for (cmd) |arg| {
defer first = false;
var needs_quote = false;
for (arg) |ch| {
if (!std.ascii.isPrint(ch) or ch == '"' or ch == ' ' or ch == '*' or ch == '$') {
needs_quote = true;
break;
}
}
if (!first)
try writer.writeByte(' ');
if (needs_quote) {
try writer.writeByte('\'');
try writer.print("{}", .{std.fmt.fmtSliceEscapeUpper(arg)});
try writer.writeByte('\'');
} else {
try writer.writeAll(arg);
}
}
}
pub fn fmtCommand(cmd: []const []const u8) std.fmt.Formatter(formatCommand) {
return .{ .data = cmd };
}

View file

@ -17,6 +17,7 @@
(mklink "scripts/map-touch-display.rkt" (bin-path "map-touch-display"))
(mklink "scripts/startriver.sh" (bin-path "startriver"))
(mklink "scripts/update-nvim-plugins.rkt" (bin-path "update-nvim-plugins"))
(mklink "scripts/use-country-mirrors.sh" (bin-path "use-country-mirrors"))
;; Compile scripts
(install-rust "scripts/i3status")