Skip to content

Commit 8255bf0

Browse files
fieldingclaude
andcommitted
Use Human++ palette for all colored output
Switch from ANSI basic colors to Human++ true-color palette: - Additions: quiet green (base13 #61b186) - Deletions: quiet red (base10 #c8518f) - Hunk headers: cyan (base0C #1ad0d6) - Stat +/-: green/pink (base0B/base08) - Context lines: fg dim (base04 #828079) - Log hashes: amber (base0A #f2a633) - Log dates: fg dim (base04) - Show commit hash: amber (base0A) - Status staged: bold green (base0B) - Status unstaged: bold pink (base08) - Status untracked: fg dim (base04) Fix color.zig naming: hpp_teal -> hpp_green (base0B is green, not teal). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent eeff071 commit 8255bf0

5 files changed

Lines changed: 27 additions & 17 deletions

File tree

src/cmd/log.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub fn run(repo: *c.git_repository, human: bool, count: usize, w: *Writer) !void
3737
const d = fmt.epochToDate(c.git_commit_time(commit));
3838
if (use_color) {
3939
try w.print("{s}{s}{s} {s}{d}-{d:0>2}-{d:0>2}{s} {s}\n", .{
40-
color.yellow, short_hash, color.reset,
41-
color.dim, d.year, d.month, d.day, color.reset,
40+
color.hpp_amber, short_hash, color.reset,
41+
color.hpp_fg_dim, d.year, d.month, d.day, color.reset,
4242
summary,
4343
});
4444
} else {

src/cmd/show.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn run(repo: *c.git_repository, human: bool, stat: bool, rev: ?[]const u8, w
4242
const d = fmt.epochToDate(c.git_commit_time(commit));
4343

4444
if (use_color) {
45-
try w.print("{s}commit {s}{s}\n", .{ color.yellow, full_hash, color.reset });
45+
try w.print("{s}commit {s}{s}\n", .{ color.hpp_amber, full_hash, color.reset });
4646
try w.print("{s}Author:{s} {s} <{s}>\n", .{ color.bold, color.reset, name, email });
4747
try w.print("{s}Date:{s} {d}-{d:0>2}-{d:0>2}\n", .{ color.bold, color.reset, d.year, d.month, d.day });
4848
} else {

src/cmd/status.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn writeHuman(status_list: ?*c.git_status_list, count: usize, w: *Writer) !void
8080
}
8181

8282
if (has_staged) {
83-
if (use_color) try w.print("{s}staged:{s}\n", .{ color.bright_green, color.reset }) else try w.writeAll("staged:\n");
83+
if (use_color) try w.print("{s}{s}staged:{s}\n", .{ color.bold, color.hpp_green, color.reset }) else try w.writeAll("staged:\n");
8484
for (0..count) |i| {
8585
const entry = c.git_status_byindex(status_list, i);
8686
if (entry == null) continue;
@@ -89,7 +89,7 @@ fn writeHuman(status_list: ?*c.git_status_list, count: usize, w: *Writer) !void
8989
if (label) |l| {
9090
const path = if (entry.*.head_to_index != null) entry.*.head_to_index.*.new_file.path else continue;
9191
if (use_color) {
92-
try w.print(" {s}{s}:{s} {s}\n", .{ color.green, l, color.reset, std.mem.span(path) });
92+
try w.print(" {s}{s}:{s} {s}\n", .{ color.hpp_quiet_green, l, color.reset, std.mem.span(path) });
9393
} else {
9494
try w.print(" {s}: {s}\n", .{ l, std.mem.span(path) });
9595
}
@@ -99,7 +99,7 @@ fn writeHuman(status_list: ?*c.git_status_list, count: usize, w: *Writer) !void
9999

100100
if (has_unstaged) {
101101
if (has_staged) try w.writeByte('\n');
102-
if (use_color) try w.print("{s}unstaged:{s}\n", .{ color.bright_yellow, color.reset }) else try w.writeAll("unstaged:\n");
102+
if (use_color) try w.print("{s}{s}unstaged:{s}\n", .{ color.bold, color.hpp_pink, color.reset }) else try w.writeAll("unstaged:\n");
103103
for (0..count) |i| {
104104
const entry = c.git_status_byindex(status_list, i);
105105
if (entry == null) continue;
@@ -109,7 +109,7 @@ fn writeHuman(status_list: ?*c.git_status_list, count: usize, w: *Writer) !void
109109
if (label) |l| {
110110
const path = if (entry.*.index_to_workdir != null) entry.*.index_to_workdir.*.new_file.path else continue;
111111
if (use_color) {
112-
try w.print(" {s}{s}:{s} {s}\n", .{ color.yellow, l, color.reset, std.mem.span(path) });
112+
try w.print(" {s}{s}:{s} {s}\n", .{ color.hpp_quiet_red, l, color.reset, std.mem.span(path) });
113113
} else {
114114
try w.print(" {s}: {s}\n", .{ l, std.mem.span(path) });
115115
}
@@ -126,7 +126,7 @@ fn writeHuman(status_list: ?*c.git_status_list, count: usize, w: *Writer) !void
126126
if (entry.*.status != c.GIT_STATUS_WT_NEW) continue;
127127
const path = if (entry.*.index_to_workdir != null) entry.*.index_to_workdir.*.new_file.path else continue;
128128
if (use_color) {
129-
try w.print(" {s}{s}{s}\n", .{ color.dim, std.mem.span(path), color.reset });
129+
try w.print(" {s}{s}{s}\n", .{ color.hpp_fg_dim, std.mem.span(path), color.reset });
130130
} else {
131131
try w.print(" {s}\n", .{std.mem.span(path)});
132132
}

src/color.zig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@ pub const reset = "\x1b[0m";
44
pub const bold = "\x1b[1m";
55
pub const dim = "\x1b[2m";
66

7+
// Standard ANSI
78
pub const green = "\x1b[32m";
89
pub const yellow = "\x1b[33m";
910
pub const cyan = "\x1b[36m";
10-
1111
pub const bright_red = "\x1b[91m";
1212
pub const bright_green = "\x1b[92m";
1313
pub const bright_yellow = "\x1b[93m";
1414

15+
// Human++ palette (true-color)
16+
pub const hpp_pink = "\x1b[38;2;231;52;156m"; // base08 #e7349c
17+
pub const hpp_amber = "\x1b[38;2;242;166;51m"; // base0A #f2a633
18+
pub const hpp_cyan = "\x1b[38;2;26;208;214m"; // base0C #1ad0d6
19+
pub const hpp_green = "\x1b[38;2;4;179;114m"; // base0B #04b372
20+
pub const hpp_lime = "\x1b[38;2;187;255;0m"; // base0F #bbff00
21+
pub const hpp_quiet_green = "\x1b[38;2;97;177;134m"; // base13 #61b186
22+
pub const hpp_quiet_red = "\x1b[38;2;200;81;143m"; // base10 #c8518f
23+
pub const hpp_fg_dim = "\x1b[38;2;130;128;121m"; // base04 #828079
24+
1525
pub fn isTty() bool {
1626
return std.posix.isatty(std.fs.File.stdout().handle);
1727
}

src/fmt.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn humanCallback(
9999
},
100100
'H' => {
101101
if (ctx.use_color) {
102-
w.writeAll(color.cyan) catch return -1;
102+
w.writeAll(color.hpp_cyan) catch return -1;
103103
w.writeAll(slice) catch return -1;
104104
w.writeAll(color.reset) catch return -1;
105105
} else {
@@ -108,7 +108,7 @@ pub fn humanCallback(
108108
},
109109
'+' => {
110110
if (ctx.use_color) {
111-
w.writeAll(color.bright_green) catch return -1;
111+
w.writeAll(color.hpp_quiet_green) catch return -1;
112112
w.writeByte('+') catch return -1;
113113
w.writeAll(slice) catch return -1;
114114
w.writeAll(color.reset) catch return -1;
@@ -119,7 +119,7 @@ pub fn humanCallback(
119119
},
120120
'-' => {
121121
if (ctx.use_color) {
122-
w.writeAll(color.bright_red) catch return -1;
122+
w.writeAll(color.hpp_quiet_red) catch return -1;
123123
w.writeByte('-') catch return -1;
124124
w.writeAll(slice) catch return -1;
125125
w.writeAll(color.reset) catch return -1;
@@ -130,7 +130,7 @@ pub fn humanCallback(
130130
},
131131
' ' => {
132132
if (ctx.use_color) {
133-
w.writeAll(color.dim) catch return -1;
133+
w.writeAll(color.hpp_fg_dim) catch return -1;
134134
w.writeByte(' ') catch return -1;
135135
w.writeAll(slice) catch return -1;
136136
w.writeAll(color.reset) catch return -1;
@@ -157,8 +157,8 @@ pub fn writeStat(diff_result: ?*c.git_diff, use_color: bool, w: *Writer) !void {
157157

158158
if (use_color) {
159159
try w.print("{s}{d} file{s}{s}, ", .{ color.bold, total_files, if (total_files != 1) "s" else "", color.reset });
160-
try w.print("{s}+{d}{s} ", .{ color.bright_green, total_add, color.reset });
161-
try w.print("{s}-{d}{s}\n", .{ color.bright_red, total_del, color.reset });
160+
try w.print("{s}+{d}{s} ", .{ color.hpp_green, total_add, color.reset });
161+
try w.print("{s}-{d}{s}\n", .{ color.hpp_pink, total_del, color.reset });
162162
} else {
163163
try w.print("{d} file{s}, +{d} -{d}\n", .{ total_files, if (total_files != 1) "s" else "", total_add, total_del });
164164
}
@@ -186,9 +186,9 @@ pub fn writeStat(diff_result: ?*c.git_diff, use_color: bool, w: *Writer) !void {
186186

187187
if (use_color) {
188188
try w.print(" {s} ", .{path});
189-
if (file_add > 0) try w.print("{s}+{d}{s}", .{ color.bright_green, file_add, color.reset });
189+
if (file_add > 0) try w.print("{s}+{d}{s}", .{ color.hpp_green, file_add, color.reset });
190190
if (file_add > 0 and file_del > 0) try w.writeByte(' ');
191-
if (file_del > 0) try w.print("{s}-{d}{s}", .{ color.bright_red, file_del, color.reset });
191+
if (file_del > 0) try w.print("{s}-{d}{s}", .{ color.hpp_pink, file_del, color.reset });
192192
try w.writeByte('\n');
193193
} else {
194194
try w.print(" {s} ", .{path});

0 commit comments

Comments
 (0)