Say you support multiple clients or multiple projects but don't want everything on your shell at once. This script in your .bashrc
file will allow you to automatically create aliases for any directory that has it's own .bashrc file. It starts a new bash shell so no existing variables are overwritten and you can exit when needed.
For example, say you have project or client named superx
and another named johndoe
. You create a directory superx
and johndoe
. Within each you pust a custom .bashrc file and optional .superx-secrets and .johndoe-secrets file and then your shell (upon next login) will detect those files and alias them to the parent directory's name. So if I want superx
stuff, I just run superx
and vice versa for johndoe
.
Some references:
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment http://www.linuxjournal.com/content/tech-tip-dereference-variable-names-inside-bash-functions http://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash