A zsh configuration that automatically loads project-specific aliases and provides a unified dev command interface for managing development environments.
- Automatic alias loading: Automatically sources
.aliases.shfiles from your current directory and parent directories - Project-specific commands: Define custom commands per project without polluting your global shell environment
- Unified dev interface: Simple
dev startanddev stopcommands that adapt to each project - Hierarchical loading: Aliases are loaded from root to current directory, allowing inheritance and overrides
Copy the code from this gist to your ~/.zshrc file.
source ~/.zshrcIn your project directory, create a .aliases.sh file:
# ~/workspace/your_project/.aliases.sh
# Define dev start/stop commands
export DEV_START="bin/docker up && overmind start -f Procfile.dev"
export DEV_STOP="overmind quit && bin/docker down"
# Add project-specific aliases
alias rgd="bin/rails docs_generate"
alias test="bundle exec rspec"cd ~/workspace/your_project
# Start your development environment
dev start
# Stop your development environment
dev stopThe load_local_aliases() function:
- Checks for
~/.aliases.sh(global aliases) - Traverses from the current directory up to the root
- Collects all
.aliases.shfiles found - Sources them in order from root to current directory
This happens automatically when you start a shell or change directories (via the chpwd hook).
The dev command executes commands defined in $DEV_START and $DEV_STOP environment variables.
- Create
~/.aliases.shfor global aliases available everywhere - Be cautious about sourcing
.aliases.shfiles from untrusted directories