Chris Hannah

Terminal


A Better Git Command Line Experience #

I’ll start by saying that I’m the sort of person that prefers to use the command line for Git commands. But there are still occasions where I just found it annoying, such as managing huge amounts of branches, reading old diffs, and also when making a big commit, and wanting to get a quick overview of what’s being added.

For those occasions, I used Fork. Although I’m sure for my uses, I could have probably used any Git GUI. However, I’m now using a terminal UI called Lazygit. I think it’s incredible. It lets me stay in the terminal, but gives me the functionality (that I use) of a typical GUI app.

This is what it looks like:

Because it’s a terminal app, it’s full of keyboard shortcuts, that make everything super fast. For example, to pull changes, you just use a lowercase p, and to push it’s an uppercase P.

Most of them are that simple that you just tap one key, but they tend to be limited to the active panel. For example, if you want to manage branches, then the branches panel needs to be the active one. Once it’s active, you can use things like space to checkout the selected branch, n to create a new branch, d to delete, o to create a pull request, etc. There’s honestly so many that if you were to check out Lazygit, I’d recommend having a glance at the full list of key bindings.

This is obviously a small example, but here is the experience of committing files:

It’s not limited to the keyboard though, you can navigate Lazygit using the cursor as well:

After installing Lazygit, I haven’t needed to use a GUI application at all. I know some may prefer to use a GUI, but I certainly have found Lazygit so much easier to use. Especially because of the abundance of keyboard shortcuts, and also because it lets me keep my Git activity to a single terminal window.

Lazygit works everywhere, macOS, Linux, or Windows, so if you want to enhance your Git experience in the command line, I’d definitely recommend checking it out.

What I've Been Up to Over the Past Few Weeks #

It’s been a while since I actually wrote something, and that’s mainly because of my university work that’s been piling up (I finish this June!), and also because I’ve been developing a few mini projects with Swift. The latter is what I’m going to be writing about today.

Basically, over the past few weeks I’ve been getting back into using the command line more. Why is a hard question, but mainly because I’m a nerd, and it’s pretty fun!

It started when I kept seeing a trend of more of the people I follow on Twitter, either retweet or post GIFs of command line apps. It also led me to Hyper, which is a terminal application, and it’s actually built using JavaScript, HTML, and CSS. You can also customise it a ton, especially with the massive amount of themes available.

I personally, have Hyper set up with the hyper-ayu theme, and my favourite monospaced font, SF Mono.

This is getting a bit too meta, so I’ll bring it back on topic.

So I’ve actually developed four command line applications in the past two weeks, and they’ve all been build using Xcode/Swift[1]. The apps themselves are unix executable files, that can just be double-clicked and ran, but on each project I include more helpful installation/usage information.

cwiki

(Not to be mistaken with my macOS app, Qwiki)

This is the first one I made, and it was probably the easiest of them all. That’s because the majority of the code I could just reuse from my already released app, Qwiki! This app, cwiki , is just a super minimal version of that app.

You just type cwiki followed by a search query, and it will print out the most relevant matches. It does however, only print out a basic description of the articles.

Check out cwiki on GitHub.

So after the first project, I was a bit more intrigued, I decided to make a more interactive app. slink is purely a URL shortener that uses the Goo.gl API, but this lets you shorten, and also expand (Goo.gl) shortened links.

The slightly more complex functionality than before, led me to work out how options are managed in command line apps. So if you want to shorten or expand a link, just use either -s, --shorten, -e, or --expand. I also made a mini usage guide, that you can print out using -h or --help 🤓.

Check out slink on GitHub.

hacker

The third project was a bit similar to the first two, in that it made use of a few different options to return different data, but it also presented it like cwiki.

It’s a basic interface for Hacker News, and by making use of the various options, you can retrieve the new, top, and best lists.

Check out hacker on GitHub.

TitleCase

Okay this one is really simple, it makes use of Brett Terpstra’s TitleCase API, which formats a given string of text to the AP Title Case style. I actually find these types of tools perfect when writing a blog post, as usually the title is formatted incorrectly.

The API was probably the easiest one I’ve ever used. But then again, there was only one parameter, no options, and one return type.

Check out TitleCase on GitHub.


Now I guess everyone knows what I’ve been up to, so I can get back to slaving away over university work, and making some random projects!

P.S. I actually have some other really great news that I’m going to share here soon, but I’m just waiting on it being finalised a bit more.


  1. My favourite programming language 😍. ↩︎