I’ve noticed myself using the command line a lot more recently, at home, and work, so I thought I’d share a few of the little tools and handy commands that I use on a day to day basis.
Note: I use ZSH as my shell, with oh my zsh, so they may differ slightly if you’re using something different.
Aliases
The most helpful commands that I use have to be aliases for the most minor commands. But because they’re used so often, it saves so much time.
The majority of them are for two things - moving to common directories, and launching applications.
Here are a few examples of directories I have set up with aliases:
- h: home directory
- dev: developer directory where I store all projects
- tc: Text Case directory
- blb: Bulba directory
That’s just a small snippet, but usually, I have most projects set up with a very small alias. But even if I don’t have one set up for each project, I’ve got one that puts me at the root of my developer folder anyway.
As for applications, I’ve got a few that I use a lot:
- xc: Opens a
xcodeproj
in the current directory - xcw: Opens a
xcworkspace
in the current directory - vs: Opens the current directory in Visual Studio Code
- fork: Opens the current directory in Fork - A Git GUI, for when I want to dig into any conflicts.
Git
Being a developer, I use Git quite a lot. And that is where oh my zsh comes in handy, as it comes with a huge number of aliases for common Git commands. Here’s a great cheatsheet.
Here are the ones I use the most, and also what the full command is:
gco
: git checkout
- checkout branchgaa
: git add --all
- adds all changes in the current directorygc -m ""
: git commit -v -m ""
- commits the current changes with a messagegp
: git push
- pushes commits to the configured remote repogf
: git fetch
- fetches branches and tags from the configured remote repo
I’m aware that those are pretty minor commands, but they’re so much easier when they’re just one two or three letters.
Also, oh my zsh does come with an alias for committing changes with a message, but it’s gcmsg
and that’s longer than just using gc
with the -m
option.
The most used Git command I use though has to be a little ZSH function I made myself:
function gacp {
gaa; gc -m $1; gp
}
It stands for “git add commit push”, and as you can probably tell, it adds and commits the following changes, with the supplied message, and pushes it to the remote repository.
Most of the time I’m doing stuff like this:
gacp "JIRA-123 fix tests"
Woops!
FTP
I don’t use these a lot, but I do have a few aliases to update various websites. They basically use the scp
command (secure copy) to transfer files from a local directory to a remote server. Guide.
This isn’t exactly what I have, but they all follow this rough syntax:
scp -r /Users/chris/website user@123.123.123.213:../var/www/
This will recursively upload the contents of a local directory to a remote server. I use this whenever I update changes to my blog theme.
HTTP Requests
Whether I’m working on a mobile app or REST API at work, I’m usually testing various requests throughout the day. And while I sometimes use a tool like Postman, especially when I’m building a collection for QA testers, I do find it a bit cumbersome sometimes. So that means I end up resorting back to the terminal.
I’ve seen a tool called httpie which does seem to be quite good, but I’ve found curl to be good enough for my uses.
Tip: If you’re stuck with the syntax and don’t have time to wade through documentation, I’d recommend using a tool like Postman to build the request, and you can then export the curl request.
Most of the time I’m just performing GET
requests, so the syntax is simply:
curl https://dev.chrishannah.me/feed.json
If you need just the headers of the response there’s the -I
option, and if I want both the headers and body it’s a lowercase -i
.
Environment Variables
Usually, I’m using the command line because I want to test quite quickly, and with slight tweaks, so I find making the command as short as possible helps with this.
The first one for me is to use environment variables. So for example I’ll use one for the base URL of the API, and usually a few for any variables that need to be in the path, especially if these are user account numbers, as it makes it a lot easier to quickly test different scenarios.
This means that a request like this:
curl https://company.com/api/account/2a3e4832-14e6-430d-8c34-748f4626e864/transactions
Can be made a lot shorter by using two environment variables:
export base=https://company.com/api
export account=2a3e4832-14e6-430d-8c34-748f4626e864/transactions
Which means it can look like this:
curl $base/account/$account/transactions
The biggest benefit I find is that allows you to edit the command much easier.
Using Files
Another tip I have for curl is that if you have a bunch of headers that you need to use, then it helps to have these stored in a file.
You can do this by using the -H
command followed by @
and then the filename. For example, this command will read the headers from a file named headers.txt
:
curl https://website.com -H @headers.txt
The header file needs to be in this format:
Key: Value
So something like this would work:
Content-Type: application/json
Authorization: Bearer [token]
This is especially handy for me as most of our APIs at work require various authorisation tokens that can be quite large.
You can also use other options to use files for storing the body of the request, but I’ve not had much experience of that, so I’ll have to defer to google.
JSON
This goes hand-in-hand with making HTTP requests, in that the responses are usually JSON. For that I use the JSON processor, jq.
Most of the time, I’m just using it to “beautify” data from a curl request, so I pass through the response to jq
by piping the output from curl
to jq
like so:
curl https://dev.chrishannah.me/feed.json | jq
What that does is take the response from the curl request and output a pretty printed version of it.
But you can also use jq
to parse the JSON response and pick out certain fields.
So for example, a request to my blogs JSON feed at https://dev.chrishannah.me/feed.json
will return a fair bit of JSON data. Something like this:
{
"version": "https://jsonfeed.org/version/1",
"title": "Chris Hannah's Dev Blog",
"home_page_url": "https://dev.chrishannah.me/",
"feed_url": "https://dev.chrishannah.me/feed.json",
"description": "A devlog by Chris Hannah",
"author": {
"name": "Chris Hannah",
"url": "https://chrishannah.me"
},
"items": [
{ ... }
]
}
But say I only wanted to read the author
object, I’d just need to use this command:
curl https://dev.chrishannah.me/feed.json | jq '.author'
Which will return just this:
{
"name": "Chris Hannah",
"url": "https://chrishannah.me"
}
There’s a lot more it can do as well, and I’d recommend checking out these examples.
I’m sure there are tons of other resources that go into far more detail on what you can do with the command line. But I thought I’d share a few things that I use it for, just in case it might prompt others to find some ways to save themselves time!
As I’ve been getting back into development for Hydrate (a water intake tracker for iOS), I’ve been thinking about the sort of representation of myself as a developer.
When I think of a great developer, they usually have a small number of apps. Sometimes they’re all at a really high standard, but most independent developers I see, have one or two main apps, and a few more fun ones.
I have been developing for iOS/macOS for quite a few years, and I have to say most of them are dead, stale, or heading in that direction. So it’s time for a clear out. This might not be a very interesting article, but I certainly think the act of me writing this, will aid in the process.
For some background information, here is the list of apps that I’ve made for iOS/macOS, and their current status.
Name |
Platform |
Status |
Description |
Hydrate |
iOS/watchOS |
Available. |
My current work-in-progress, a water intake tracker. |
Pretty Regular Expressions |
iOS/macOS |
Available. |
Regular expression tool for macOS/iOS. Very simple. |
Pixels Sticker Pack |
iOS |
Available. |
Some pixel art iMessage stickers! |
AniMatchers |
iPhone |
Available. |
Just a fun memory matching game, with cartoon animals. |
Bill Splitter |
iOS/watchOS |
Available. |
A super basic bill splitter. Mainly a small project so I could check out the watch SDK. |
Qwiki |
macOS |
Available. |
My wikipedia menu bar app, which is one of my best projects in my opinion, which I will hopefully update soon. |
Tap Gap |
iOS |
Available. |
A quick game for iOS, where you try and tap the screen when a line is between a certain gap. |
Floppy Turd |
iOS |
Available. |
An awful, but funny remake of Flappy Birds. It took a sunday morning to create, and that was where I left it. |
TinyMe |
iOS/macOS |
Removed. |
One of my first few apps, they used the goo.gl api to shorten longer links, but they aren’t an issue anymore. |
Postie |
macOS |
Available. |
I used to blog on Scriptogram, and this was a basic Markdown editor with publishing built in. The service has unfortunately shut down. |
The Girlfriend Helper |
iOS |
Removed. |
I think the first app I made. It was an app that suggested message you could send to your girlfriend depending on the event type. |
Halloween FX |
iOS |
Removed. |
Basic soundboard app, which also featured a timer so you could hide your phone and scare someone. |
The Farm |
iOS |
Removed. |
Even more basic soundboard app, just contained farm animals. |
Bug Splatter |
iOS |
Removed. |
This was a weird one, there’s multiple levels of bugs/difficulty, and the aim was to splat as many of them before they reached the end of the screen. |
Whack |
iOS |
Removed. |
A pretty simple whack-a-mole game, but with pixel art, and funny noises. |
TextShot |
macOS |
Never made it. |
This was a really fun project to work on, it was going to be an app where you could select a bunch of text, and it would generate a picture from it, even including multiple different styles. Sadly the MacBook I was using at the time died completely, and I wasn’t clever enough to think about source control back then. |
Okay, I didn’t actually know I already removed a few of these already. But there’s still some clearing out to do.
My aim is to have a small number of applications, that either are stable, and need hardly any maintenance, or ones that I can regularly keep updated, and are proven to be worthwhile.
So if you just take the apps I have available, there’s 9. Well one isn’t released yet, but it’s in progress.
- Hydrate
- Pretty Regular Expressions
- Pixels Sticker Pack
- AniMatchers
- Bill Splitter
- Qwiki
- Tap Gap
- Floppy Turd
- Postie
If I separate them into the groups I mentioned before, I’m left with this:
Maintainable Apps:
- Hydrate
- Qwiki
- Pretty Regular Expressions?
Minimal Effort/Stable Apps:
- Pixels Sticker Pack
- Tap Gap
Left over:
- AniMatchers
- Bill Splitter
- Floppy Turd
- Postie
That was pretty quick and easy, and it sort of represents what I already had in my head. Out of the four left over, they all have very good reasons why I don’t want to support them anymore. Low download numbers, super old code, and lack of interest to work on them again.
So, they’re be removed.
That leaves just five remaining apps, three I feel that are maintainable, and the other two are kind of eternal to an extent.
Of course Hydrate will stay, I mean I haven’t even released it, and it’s still in active development. Qwiki is stable, and my most popular app, so that will also stay.
Pretty Regular Expressions however was initially well taken, but I haven’t had any desire really to go back to it, and improve it. I will have a look at the code again, and hopefully I can add something to make the app even better soon.
Pixels Sticker Pack is a bunch of images, and I can’t see myself ever needing to update these. They’re fun, and I still enjoy using them!
That leaves Tap Gap, it’s a simple game, that still works fine. I’ll certainly make a few changes and support the iPhone X soon, but that is only a minor issue.
So the remaining apps, along with their pricing are:
Not a bad bunch!
I’ll be checking out a few of these projects today, and maybe even get thinking about the changes/updates I can make!
If you want to follow on with more detail, just follow me on twitter!
If you’re a programmer, you’re probably aware about version control and Git, and maybe even what a .gitignore
file is.
If you don’t:
A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below for details.
Anyway, creating these files can be annoying to write manually, and there a bunch of templates all over the internet to make this much easier.
I however, found a much better solution for creating these files, and it’s gitignore.io. It’s a website that you can use to generate a .gitignore
file, but also a command line tool that you can use, so you never have to leave your terminal.
It has support for operating systems, IDEs, and programming languages. So my standard file will be generated from macOS, Xcode, and Swift, since that’s how I roll.
You can type (with autofill of course) whatever templates you want to make use of straight into the website, and then hit ‘Create’.

For the command line, you’ll have to first install it, and then the gi
command will be available. All you need to do is type gi
followed by a comma-separated list of the same items you would use on the website.
So mine would be:
gi macos,xcode,swift
.
The command would of course, output this out via the standard output, so you can direct it straight into your .gitignore
file by writing something like:
gi macos,xcode,swift >> .gitignore
It’s super easy, and it saves a lot of time.
As a little bonus, there’s also a quick video on how to install and use the command line tool.
I made my first API today, and I used Swift to do it!
Basically, I got bored this afternoon and decided to have a little research into server-side Swift programming. I’ve heard about this before, but I’ve not gone too deep into it myself.
The problem with me tying things like this, is that I ever really have a good idea, or scenario which I could use to learn the new thing. Well as you may already know, I’m slowly working on a title casing application for iOS and macOS, and therefore I’ve already created a few functions to format text.
So far the base TextCase functions are:
- Uppercase
- Lowercase
- Title Case
- URL Encoding
- Mocking SpongeBob (yes, like the meme)
From these formats, the only ones I could see being useful are Title casing, and the fun SpongeBob format.
From making use of various APIs myself, I knew that all I needed was a super simple HTTP server, which had support for a few GET requests.
Perfect was the tool I used to write the server side code, and I found a quick tutorial which explained the basic HTTP server that I needed. I must say it was really easy for me to create this, as I’m already familiar with Swift, so the only thing to learn was the “Perfect” way of doing things.
Because it was in Swift, I could also reuse my main TextCase class which handles the formatting. There was a slight exception, where the arc4random_uniform
function isn’t available on Linux, but I found a Linux suitable replacement for this.
There are also a few more reasons why I wanted to try this out, but they’re rather meta. For example, I’m a big fan of Swift, and it feels good working with “low-level” Swift if you can really call it that, and also because I just love the look of Swift in the default Xcode theme, with the SF Mono font 😍 (weird, I know, but it’s the truth).
The final code (as in what I’ve done so far), is three endpoints, which are actually just two. /title/{input text}
is to return the given text in title casing, /spongebob/{input text}
is for the SpongeBob case. The third one is just /{input text}
, and it returns the text in every format available, which is just the two I mentioned so far. The results are in plain JSON, and also include the plain value that was sent in the request.
For example, here is an example response to the /
endpoint:
{
"plain" : "what the hell is this",
"title" : "What the Hell Is This",
"spongebob" : "wHAT ThE Hell iS thiS"
}
Anyway, you can view the project over at GitHub, and if you want to suggest any new formats (or even write some yourself), just let me know on Twitter at @chrishannah
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. 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.
slink
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.