Skip to content

Modifying the Global Environment

Max edited this page Apr 6, 2016 · 2 revisions

When using ZENv, you'll find yourself modifying the global environment for most of your tasks. You'll need to do it to add a new tool, to change environmental constants, and to modify how people's shells start up. Each of those things is easily doable by modifying different files.

Adding Developer Tools

ZENv places its bin folder in the user's $PATH variable, so any tools that you place there are runnable. Try doing this:

cd "$ZENV_ROOT"
echo 'echo "Hello, World!"' > bin/hello
chmod +x bin/hello
hello

This will create a developer tool called hello that you can now run from anywhere! Check out the other tools in the bin folder for more useful things.

Changing How the Shell Starts

On shell startup, ZENv will first load the .zenvrc file, then execute every .sh file in its environment folder. This gives you the opportunity to set new variables, add functions, and make changes.

For example, environment/vars.sh sets up several color variables (useful for printing in color in scripts), as well as changes the prompt and enables an additional git config file. All of the variables that it sets are available globally, whether in the shell or by accessing environment variables from a program or script.

Something that might be very useful is including Shawn O. Pearce's excellent git tab completion script in your environment folder. If you rename the script to end with .sh, it will run on startup and enable tab completion of git commands.