diff options
| author | WormHeamer | 2026-01-01 04:29:20 -0500 |
|---|---|---|
| committer | WormHeamer | 2026-01-01 04:29:20 -0500 |
| commit | 701af52ee94cf7a659856d24fff7145368a3650e (patch) | |
| tree | 449117c003e9642db1aaf0544a0b0a18ca74883a | |
| parent | 74ea1e9de26f1ac7cffd193af6215f44b3b8b744 (diff) | |
add git commands
| -rw-r--r-- | main.c | 46 |
1 files changed, 42 insertions, 4 deletions
@@ -391,6 +391,38 @@ int shell_run(const char *cmd) { return r; } +const char *expand_cmd(const char *src) { + DYNARR(char) s = { 0 }; + u32 n = strlen(src); + for (u32 i = 0; i < n; i++) { + if (src[i] == '%') { + i++; + if (src[i] == '%') { + DA_APUSH(&s, &e.scratch, '%'); + } else { + DA_APUSH_MULT(&s, &e.scratch, + e.buf[e.bufi].path.s, + e.buf[e.bufi].path.n); + if (i < n) { + DA_APUSH(&s, &e.scratch, src[i]); + } + } + } else { + DA_APUSH(&s, &e.scratch, src[i]); + } + } + DA_APUSH(&s, &e.scratch, '\0'); + return s.v; +} + +int shell_run_no_prompt(const char *cmd) { + vui_disable(); + int r = system(expand_cmd(cmd)); + vui_enable(); + vui_redraw(); + return r; +} + /* main */ void find_view_window(TxtLoc l, TxtLoc *start, TxtLoc *end, u32 lines) { @@ -1150,10 +1182,16 @@ int main(int argc, const char **argv) { debug_file(eb->path); break; case 'e': - vui_disable(); - system("make clean"); - vui_enable(); - vui_redraw(); + shell_run_no_prompt("make clean"); + break; + case 'l': + shell_run_no_prompt("git log --oneline %"); + break; + case 'd': + shell_run_no_prompt("git diff %"); + break; + case 'c': + shell_run_no_prompt("git add % && git commit %"); break; default: /* TODO: flash */ |
