DEV Community

Natalia Venditto
Natalia Venditto

Posted on

My command line cheatsheet

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. It was free...easy to use. A bit later, everyone in my team was given a license to the bit more complex Tower.

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 or ohmyzsh 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

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!

Top comments (6)

Collapse
 
devmount profile image
Andreas

Thank you for this awesome little cheatsheet! Didn't know about cd - thats awesome!

"Sometimes you remember part of a command but not all of it."

I always use CTRL+R for triggering an interactive reverse search in command history (it even works for your complete history, not only for your current session).

Collapse
 
anfibiacreativa profile image
Natalia Venditto

That's a great tip!

Collapse
 
dividedbynil profile image
Kane Ong • Edited

Nice cheatsheet!
I think the history grep | whatyouremember should be history | grep whatyouremember.

Collapse
 
anfibiacreativa profile image
Natalia Venditto

you're right! It gets messy when you type it outside of the command line :D

Collapse
 
gubaros profile image
Guido Barosio

Meh, yeah, but not. Git is beautiful from a command line perspective. It's like learning vi -once mastered- it becomes more important than your blood factor.

Collapse
 
anfibiacreativa profile image
Natalia Venditto

I agree with you! This is why I only created aliases when I knew those commands like the palm of my hand :D