The Secret Senior Dev Trick to Never Re-type Commands
Teqani Blogs
Writer at Teqani
This article provides a simple yet effective solution to organize your terminal aliases, preventing your .zshrc or .bashrc file from becoming a chaotic mess. By creating separate alias files for different tasks like Git and Flutter, you can maintain a cleaner and more manageable development environment.
Step 1: Know Your Shell
Before diving in, determine which shell you're using. On macOS (Catalina and later), it's likely zsh. Older versions might use bash. You can check by running echo $SHELL in your terminal.
Step 2: Create a Folder for Your Aliases
Create a directory to store all your alias files:
mkdir ~/.aliases
Step 3: Create Separate Alias Files
Create individual files for different alias categories, such as Git and Flutter:
touch ~/.aliases/git_aliases.zshtouch ~/.aliases/flutter_aliases.zsh
Step 4: Connect Them to Your .zshrc Using a Variable
Open your .zshrc file (nano ~/.zshrc) and add the following block:
ALIAS_DIR="$HOME/.aliases"
for file in "$ALIAS_DIR"/*.zsh; do
[ -f "$file" ] && source "$file"
done
This block defines a variable ALIAS_DIR to store the path to your aliases folder. The for loop then iterates through each .zsh file in that folder and sources it, loading the aliases into your shell.
Why This Is Better
- Easy to update alias folder location.
 - Keeps your .zshrc clean and readable.
 - Simplifies adding new alias files.
 
Restart your terminal, and you're done! This organized approach saves time and keeps your coding environment manageable.
All blogs are certified by our company and reviewed by our specialists
Issue Number: #3f27d193-d603-4a75-aa5a-b67654a1abde