Customizing your shell environment: The ENV variable

So far, we have discussed customization that is set up inside your .profile file. However, the shell reads your profile file only when you log into the shell or when you enter the sh command –L option.

To always have a customized shell session, you need to have a special shell script that sets up the environment started each time you start the shell; this is called a login script (also known as an environment file, or startup script). You specify the name of this script in the ENV variable in your .profile file.

When you start the shell, the shell looks for an environment variable named ENV. You can use the ENV variable to point to a login script that sets up things in the same way that the profile file does.

For example, you might put all your alias definitions and other setup instructions into a file called .setup in your home directory. You want these instructions run when your shell starts after you login and whenever you explicitly create the shell during a session (for example, as a child shell to run a shell script). To make sure that ENV is set up when you login or when you execute a shell, specify export ENV in your .profile file.
export ENV=$HOME/.setup 

You might find it useful to put all your aliases in the login script that ENV points to, instead of in your .profile file. However, you should keep exported variable assignments in your profile, so that they are run only once.