extrawurst's blog

terminal ui for git written in rust

• general

Today it is time to announce gitui:


Over the last couple of weeks, my side project was this little tool and some may know it from the occasional tweet already:


gitui is becoming my GUI alternative for using git. So far it only supports a few features but my goal is to extend it as needed. My focus is not to build a git cli substitute though, gitui is supposed to help out on tasks that are cumbersome to do on the cli for pure mortals like me. The main features so far:


Q: Why not use the raw git cli?
A: Complex tasks are hard to do. I googled for how to rebase stuff interactively or stage hunks often enough to realise that some people just need something more visual.

Q: Why don’t you use the GUI application {insert name}?
A: I tried a lot of them, they do much more than I need, tend to be super slow and grinding to a halt on bigger repos and one after the other starts to cost money.

Q: Why not build yet another GUI application?
A: GUI applications are complex, most of them are not free because of this. If you do most of your work in the terminal, its natural not to have to leave it for your git interaction. Plus it gives me this nice nostalgic feeling ;).

Q: Isn’t there already such a tool?
A: The idea of a terminal UI for git isn’t new, there is great examples out there: tig and lazygit They are both awesome and inspired me but either I found them too slow/resource-hungry in some areas or too complicated to use and navigate in others. (maybe a little NIH-syndrome as well).

Q: Why in Rust?
A: I started using Rust two years ago, first out of fun, then professionally and so far there was no project to build something out in the open. gitui gave me the opportunity to opensource something built in Rust and I think it’s a great fit for the kind of tool it is.

Benefits of using Rust

Disclaimer: First of all, of course gitui could have been written in any language. I don’t want to start language wars here.

My personal background is that I started out as a C++ programmer, system programming languages always appealed to me. Still I appreciated the comfort of managed systems like Java, C#, Node/Javascript and lately also Go. Over the years I kept watching out for something though that combined the strength of those two worlds. I think I found that in Rust:

  1. safety
    • Rust has a unique memory model that offers me bare metal control without sacrificing safety
  2. speed
    • It is a system level language, you can be as fast as C, people wrote os kernels in it, no GC, no pauses, the sky is the limit 🚀
  3. ergonomic
    • closures, generics, functional, abstraction, modularization - everything but inheritance
  4. interop
    • seamless c interop allows to tap into a huge ecosystem of existing libraries and frameworks
  5. ecosystem
    • cargo+rust == npm+nodejs == gradle+java
    • I really don’t know how I was surviving without such a rich and tightly integrated ecosystem of libraries in C/C++ before

Of course gitui is not re-inventing the wheel at all. It is standing on the shoulders of giants using the following major dependencies:

what why
crossterm + tui-rs crossterm is a cross platform terminal library and tui-rs builds an immediate mode UI layer on top of that
git2-rs git2-rs is a rust wrapper on top of libgit2 allowing to work with git natively (not having to call the commandline)
rayon on the topic of concurrency: gitui uses rayon for its threadpool
crossbeam more concurrency: crossbeam allows waiting (selecting) multiple channels in parallel

There is much more to say about how gitui utilizes Rust’s strengths but this post is getting out of hand already. More details will follow in the next post

Next steps


comments powered by Disqus