Handy terminal aliases

Photo by Markus Spiske on Unsplash

Updated January 16th, 2023
By Jona Ittermann

Getting work faster done in the terminal using aliases

Useful things for (almost) everyone!

When working in the terminal and hacking everything using commands, you might have to retype a whole bunch of commands.

The following list is a small collection of things I'm using to speed up the work in the terminal.

Credits: I've spotted most of these commands in the setup of CJ with the CodingGarten. So you might also want to check out his setup for more tips.

General commands

To get started, some general commands:

.bashrc
# Navigation made easier
alias ..="cd .."

# Creating folders
function mcd() {
    mkdir $1 && cd $1
}

# Deleting files and folders
alias rd="rm -rf"

Jumping between a lot of directories and files can get exhausting, if you have to type commands over and over again. Using this alias and the function, you just have to type .. to move a directory up or mcd this-is-a-new-dir to create and directly move in this directory.

Last but not least, once you have to delete everything - so directories and files - the best way might be to use rm -rf delete-this-folder. Just add a alias for it and your life get's a bit easier!

Git commands

Next up: Git commands:

.bashrc
alias gs="git status"
alias gf="git fetch"
alias gp="git pull"
alias gc="git checkout"
alias ga="git add"
alias gaa="git add ."
alias gcm="git commit -m"
# Push to master branch
alias gpm="git push -u origin master"
# Push to currently checked out branch
alias gpc="git push -u origin $(git branch --show-current)"

Since a few months I enjoy managing my git repos directly within the terminal.

Yes, some things are easier via a GUI - there I use Intellij and their great Git integration - but for quickly committing and pushing changes to the remote repo the terminal is perfect!

And yes, if you are into SVN instead of Git, you can also adapt the above commands to use with SVN.