The following snippet for your ~/.zshrc will look for .aws_profile in the a directory after entering it. In case the file exists it will use the asp function to set your profile according to the content of the file.
1 2 3 4 |
function chpwd() { emulate -L zsh test -f .aws_profile && asp $(cat .aws_profile) } |
This feature is meant to be used in conjunction with the clouds tool for easy CloudFormation stack management from the shell that can be found here: https://github.com/cristim/clouds
You can add as much code as you like to be executed on changing the current directory (e.g. activate a Python virtualenv) but be sure not to overload it or changing directories can become a pain.