How to set global environment variables using shell script .sh

前端 未结 3 765
眼角桃花
眼角桃花 2021-01-17 06:01

I have a .sh file that locally sets some environment variables in my shell source my_env.sh.

#!/bin/sh
echo \"Setting up local env         


        
3条回答
  •  星月不相逢
    2021-01-17 06:31

    If you are using bashrc or zshrc you can source the shell file which sets the environment variables across the sessions or precisely loads all the environment variables in each session.

    source location/shell-script-sets-env.sh  
    

    The zshrc and bashrc is available in your $HOME directory. or ~/.zshrc and ~/.bashrc. The current shell can be looked via

    echo $SHELL 
    

    Have a look at setting env permanently for adding it to the profile.

提交回复
热议问题