My command line cheatsheet
Tags: terminal, bash, javascript, git
Published: 2020-04-15 21:53:00

---
title: My command line cheatsheet
published: true
description: A list of alias and other useful commands I use on a daily basis
tags: terminal, bash, js, git
---

A while ago I did a post on twitter disclosing my git aliases. Today I will tell a bit more about my use of the terminal.

## A little tale

I started as a graphic designer, I told that story already. So back when I started developing... (well back then I did not even use version control, but let's not go there!)... so back then, I still really badly needed a GUI. I started with [Sourcetree](https://www.sourcetreeapp.com/). It was free...easy to use. A bit later, everyone in my team was given a license to the bit more complex [Tower](https://www.git-tower.com/). 

But...I did not really know what was going on and what commands were being executed when I was clicking buttons. One day I decided I was not going to use a GUI for git anymore. 

And I switched to the terminal. Not [iTerm2](https://www.iterm2.com/) or [ohmyzsh](https://ohmyz.sh/) or anything fancy. Just the default mac bash terminal.

To this day, I use it with the default Homebrew theme. It's really fluorescent. It's not pretty at all! But somehow, I like it...


## Git alias time!

But typing git commands was time-consuming. Sometimes I was in demos, conferences, meetups, alignments, and I was mistyping the same command 3 times. But writing those long strings of commands over and over helped me learn them, and what they did. Once I had learned them by heart I got aliases for them, and here is my git aliases cheatsheet! Remember this [alias] go in your .gitconfig file

{% gist https://gist.github.com/anfibiacreativa/b5b6595bdfec729f62cdf49142c043ad %}

That also means that when I want to find a branch called something with some JIRA-ID or some particular string in the name, I run

`git bll | grep JIRA-ID`

because you can complete those alias with any additional commands you need, or flags.

## Other super useful short commands

Speaking of grep, the other day I commented on another Twitter thread where somebody complained about having to hit the up arrow a bazillion times to find a certain command. Sometimes you remember part of a command but not all of it. In mac bash (not sure other systems), you can run

`history | grep whatyouremember`

and it will return a match in your commands history for that tab.

Another super useful command when you switch between directories to run builds at different levels is this one:

`cd - `

That's it! That will bring you to the last path you were executing commands at, before the one you're at now. (That's thanks to my friend and colleague Felipe, who knows a lot about many things)

Other commands I have aliased are the ones that build my AEM instances for many projects. Usually, you need to pass a profile or another, sometimes the port, the host, etc, and you end up with a very long command. These aliases go in the .bashrc file

`mvn clean install -PinstallPackage -DskipTests=true NPM_SOME_CONSTANT_FOR_MY_FEBUILD=` would be aliased to

`i[valueofthatconstant]`

And I think, that's mostly it...My life is easier now, and I hope yours is too. Have a great evening!