diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 9f80e77..de7da70 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -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 diff --git a/scripts/mzteinit/src/env.zig b/scripts/mzteinit/src/env.zig index 4ebbbca..1383fdb 100644 --- a/scripts/mzteinit/src/env.zig +++ b/scripts/mzteinit/src/env.zig @@ -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(); diff --git a/scripts/mzteinit/src/util.zig b/scripts/mzteinit/src/util.zig index 800af44..1c76559 100644 --- a/scripts/mzteinit/src/util.zig +++ b/scripts/mzteinit/src/util.zig @@ -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 }; +} diff --git a/setup/commands/install-scripts.rkt b/setup/commands/install-scripts.rkt index 45dce74..7a25759 100644 --- a/setup/commands/install-scripts.rkt +++ b/setup/commands/install-scripts.rkt @@ -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")