diff --git a/git-prompt.c b/git-prompt.c index 0a2a08e..87a7cd3 100644 --- a/git-prompt.c +++ b/git-prompt.c @@ -21,6 +21,11 @@ } #endif +#define color8(CODE) "\e[3" #CODE "m" +#define color256(CODE) "\e[38;5;" #CODE "m" +#define bold "\e[1m" +#define reset "\e[0m" + typedef struct process { pid_t pid; FILE* out; @@ -104,7 +109,7 @@ int main() { } char* branch = trim(branch_buf); char prompt[1024] = {}; - append(prompt, 3, " %{%F{66}%}", branch, "%{%f%}"); + append(prompt, 3, " " color256(66), branch, reset); // get the upstream remote if one exists char command[1024] = {}; @@ -178,22 +183,22 @@ int main() { if (indexed || modified || deleted || unmerged || untracked) { // modified char int_buf[32]; if (indexed) { - append(prompt, 3, "%{%F{2}%}*", inttostr(int_buf, indexed), "%{%f%}"); + append(prompt, 3, color8(2) "*", inttostr(int_buf, indexed), reset); } if (modified) { - append(prompt, 3, "%{%F{1}%}+", inttostr(int_buf, modified), "%{%f%}"); + append(prompt, 3, color8(1) "+", inttostr(int_buf, modified), reset); } if (deleted) { - append(prompt, 3, "%{%F{1}%}-", inttostr(int_buf, deleted), "%{%f%}"); + append(prompt, 3, color8(1) "-", inttostr(int_buf, deleted), reset); } if (unmerged) { - append(prompt, 3, "%{%B%F{1}%}×", inttostr(int_buf, unmerged), "%{%f%b%}"); + append(prompt, 3, bold color8(1) "×", inttostr(int_buf, unmerged), reset); } if (untracked) { - append(prompt, 1, "%{%F{1}%}…%{%f%}"); + append(prompt, 1, color8(1) "…" reset); } } else { // clean - append(prompt, 1, "%{%B%F{2}%}✓%{%f%b%}"); + append(prompt, 1, bold color8(2) "✓" reset); } // print the prompt