Create Shortcut(Alias) Commands in MacOS or Linux Terminal
Create Laravel Shortcut Commands for php artisan in MacOS or Linux
If you are a developer like me and mostly like to use CLI(Command Line Interface), in this case (Our BMW Terminal of the MacOS). Sometimes, we have to type long commands, which we often use.
It gets irritated ti type long commands again and again. To overcome this problem, MacOS and Linux both provides us a beautiful solution, and its name is “.bash_profile”.
.bash_profile is a file, which resides in the root directly of the MacOS or Linux OS.
So, if you are working on a MacOS or Linux, I’ll tell you how to create “.bash_profile” and how to use it. I’m also going to share some of my really easy shortcuts for the long commands of Laravel, which I have made while working with Laravel during these years of my development.
So, I’m not going to take more time now, Let’s start:-
Step: 1 — open your terminal, either you have a MacOS or Linux. Steps are same. Goto the root directory. and create a new file .bash_profile.
if you already have this file “.bash_profile”, you can edit it using nano editor(you can also use ‘vim’ if you like.).
All the files starting with dot(.) are hidden file. So, if you want to check the files in the directory. You can use $ ls -a
$ cd nano .bash_profile
Step: 2 — Now we will create some shortcuts using alias in the .bash_profile
suppose you have installed MAMP in your MacOS or LAMP in your Linux, and you want to goto htdocs or www folder in the terminal.
you can make this shortcut.
alias _ht=’cd ˜/Applications/MAMP/htdocs’
I use _ (underscore) in front of my own created shorcuts. This path is for the MacOS users, if you are Linux user or you have installed MAMP somewhere else, set your path accordingly.
and These are some Laravel and NodeJS shortcuts, which you can use.
alias _laravel=’composer create-project laravel/laravel’
alias _pa=’php artisan’
alias _pas=’php artisan serve’
alias _nrs=’npm run start’
alias _nrd=’npm run development’
You can create as many shortcuts as you want.
I have also written some interesting Laravel, JS and ReactJS snippets for VSCode, which makes the coding so much fast. If you want to know, please let me know in the comments.
Hope you enjoyed this article.
Don’t forget to share and Bookmark this article. :)