Do you often find yourself typing a long command on the command line or searching on the internet when you need it? If yes, then bash aliases will avoid your headache. Bash aliases allow you to set a shortcut command.

I will explain how to create bash aliases so you can be more productive on the command line and finish your work quickly. I will also provide some useful aliases which might help you.

Creating Bash Aliases

Creating aliases are very straight forward. The syntax is as follows:

alias ALIAS_NAME="COMMAND_TO_RUN"

Open the file in text editor.

nano ~/.bashrc
or 
sudo nano ~/.bashrc

As i am a PHP/Laravel developer i have created some aliases as fellows.

# Aliases
# alias ALIAS_NAME="COMMAND_TO_RUN"

alias pa="php artisan"
alias pamm="php artisan make:model"
alias pamc="php artisan make:controller"
alias cdump="composer dumpautoload"

The aliases should be named in a way that is easy to remember. It is also recommended to add a comment for future reference. You can use # keyword to add comments.

#Laravel Alias

Now run one of the alias command in the terminal. Enjoy!

Author

I am a Laravel developer with some other skills.

Write A Comment