💻 Supercharge Your Mac Terminal with Custom Command Shortcuts Using .zsh
If you’re a developer working on macOS, you likely repeat certain terminal commands every day. Whether it’s Laravel’s php artisan, Git commands, or anything else, typing the same long commands again and again can slow you down.
But what if you could shorten php artisan migrate:fresh --seed to just fresh? Let’s show you how.
🎯 Step 1: Create Your Custom Command File
First, create a file where you’ll store your aliases. You can place it inside your .ssh directory or anywhere you like:
nano ~/.ssh/mycommand.zsh
Paste your aliases inside the file:
# Laravel Artisan shortcuts
alias art='php artisan'
alias fresh='php artisan migrate:fresh --seed'
# Git shortcuts
alias ga='git add '
alias gst='git status '
alias gdiff='git difftool --tool=opendiff '
alias gcm='git commit -m '
alias gp='git push'
alias gpl='git pull'
Save and close the file (Ctrl + X, then Y, then Enter).
⚙️ Step 2: Source It in Your Terminal
Now, make sure your terminal can load this file. Run the following command:
source ~/.ssh/mycommand.zsh
From this point onward, you can start using your new shortcuts right in your terminal session.
🔁 Step 3: Auto-Load on Terminal Start (Optional)
To make sure your aliases are always available when you open a new terminal window, add this line to your ~/.zshrc file:
source ~/.ssh/mycommand.zsh
Then reload the config:
source ~/.zshrc
🧪 Examples
Now you can type:
fresh # Runs php artisan migrate:fresh --seed
gst # Runs git status
gdiff # Uses opendiff for git diffs
🚀 Conclusion
Small time-saving shortcuts like these can greatly improve your daily development workflow. By spending just a few minutes setting up aliases, you’ll save hours over time—especially when switching between Laravel and Git commands frequently.
Happy coding! ⚡


There are 0 comments