Skip to content

ZSH plugin loads the configured scripts when entering into the specified directory

License

Notifications You must be signed in to change notification settings

Ajnasz/zsh-dir-profile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

ZSH Directory profile

ZSH plugin loads the configured scripts when entering into the specified directory

Ideal to set environment variables automatically.

Configuration

Add the configuration to your .zshenv (or .zshrc) file:

typeset -a _zsh_dir_profiles
_zsh_dir_profiles=(
	"/path/to/a/directory/src/project1" "/path/to/zsh-dirprofiles/project1"
	"/path/to/a/directory/src/project2" "/path/to/zsh-dirprofiles/project2"
	"default" "/path/to/zsh-dirprofiles/default"
	)

Content of /path/to/zsh-dirprofiles/project1

export AWS_PROFILE="project1"

Content of /path/to/zsh-dirprofiles/project2

export AWS_PROFILE="project2"

Content of /path/to/zsh-dirprofiles/default

export AWS_PROFILE="default"

When you cd to /path/to/a/directory/src/project1, the project1 configuration will be loaded which sets the AWS_PROFILE environment variable to project1.

When you cd to /path/to/a/directory/src/project2, the project2 configuration will be loaded which sets the AWS_PROFILE environment variable project2.

When you enter to a directory which doesn't match to any other, the default will be loaded.

oh-my-zsh

Put/clone the plugin into your $ZSH_CUSTOM/plugins folder ($HOME/.oh-my-zsh/custom/plugins by default). Add the zsh-dir-profile plugin to the plugins list in your zshrc.

plugins=(zsh-dir-profile)

About

ZSH plugin loads the configured scripts when entering into the specified directory

Topics

Resources

License

Stars

Watchers

Forks

Languages