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.

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.

In order to use one of multiple profiles in your awscli config you need to set AWS_DEFAULT_PROFILE in your environment. This can easily be done with the following snippet in your ~/.zshrc . Profile names will be autocompleted. E.g.: asp development will activate the development profile from the config section above.