As developers, we are quite familiar with Git because it is such a crucial component of our day-to-day work. Software engineers rely on Git on a daily basis, and we can't picture a day without it.
And there are always some terminal enthusiasts who prefer to run Git and AWS CLI commands only in the terminal. Even for them, remembering and writing those long and complex commands is challenging, and writing them every day is tedious and time consuming.
Every time I use the terminal, I wonder why these commands don't have shortcuts like "s3 make bucket": "s3 mb."
But all changed lately when I was introduced to Aliases. With Aliases, we can convert a name to a nick name.
Let's see what I mean in this post, but before, there's something more I'd want to share to make everyone's life easier.
Using Z shell (also known as zsh)
Using the default terminal might be annoying at times. You want to do something different, to liven up the boring terminal and increase your productivity.
Z shell (Zsh) is a Unix shell that built on top of bash and adds a lot of features.
Zsh can be installed by running by one of the the following commands.
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" $ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
For more on Zsh Click here
If zsh is installed lets get to the Alias
Open your "zshrc" file to add all your aliases.
To open "zshrc" file use the command below
Step1: Add all your Aliases.
# Aliases alias g='git' alias gst='git status' alias gd='git diff' alias gdc='git diff --cached' alias gl='git pull' alias gup='git pull --rebase' alias gp='git push' alias gd='git diff'
Step2: Save your file.
Step3: Source the file from below command or open a new terminal.
As you can see "git status" and "gst" are performing same task.
➜ ~ git status fatal: not a git repository (or any of the parent directories): .git ➜ ~ gst fatal: not a git repository (or any of the parent directories): .git ➜ ~
We learned how to create shortcuts (aliases) for git commands, but you may add your own custom aliases and functions based on your work needs; perhaps, these aliases will spare you from all of these long and difficult commands.