Creating Aliases on Linux
One thing that always trips me up is the command to clear the terminal window. On Windows this command is just
cls but on Linux the command is
clear. Muscle memory is hard to break sometimes. The solution is to setup an alias to map
clear. It's actually really easy to do. The approach I used is to create a
.aliases file my home directory and then source that file into both the ZSH and Bash.
First, create the
.aliases file in the editor of your choice. Here I'm using nano.
In this file define any aliases you want. The syntax for an alias is
alias command=target. So for my example to map
clear would look like this.
The final step is to source the
.alias file in the
.bashrc or the config file for your terminal of choice.
Relaunch the terminal and your good to go.
The best part about this approach is that if you end up using multiple shells, you can define you custom aliases once and the reuse it any shell you want. On top of that when you come up with new alias you want to create, you've got one place to make a change.