I use direnv
to automatically set environment variables per directory.
It's great, but there's no elegant solution for aliases with direnv
.
So I rolled my own, inspired by this anser on Ask Ubuntu.
Add a few lines to your .bashrc
and your .bash_aliases
and place custom aliases into a .aliases
file in any directory.
Those aliases will be set when you enter that dir, and unset when you leave.
It's certainly not perfect and there are doubtless some gotchas, but it's pretty handy.
Add the following to your .bashrc
so whenever you start a shell, it will load the .aliases
file in whichever dir your shell has started. You should add it somewhere after your other aliases are defined/loaded.