Which folder is better for environment variables?

export UNIVER_SEARCH_ORDINARY="http://127.0.0.1/api/search/title"
export UNIVER_SEARCH_LABEL="http://127.0.0.1/api/search/common"
export UNIVER_SEARCH_VIDEO="http://127.0.0.1/api/search/result"
export UNIVER_SEARCH_UPLOAD="http://127.0.0.1/api/search/upload"
export UNIVER_TASK_MANAGER="http://127.0.0.1/api/task/manager"

I want to put these variables into the environment variables of the computer. Which file should I put in the computer?

I used to put it in / etc/profile , but now I don"t want to put it in the etc folder. What other file can I put in and read it into?

if [[ $UNIVER_SEARCH_VIDEO == $(sed "/^UNIVER_SEARCH_VIDEO=/!d;s/.*=//" /etc/profile) ]];then
    echo ${UNIVER_SEARCH_VIDEO}
else
    echo ","
    -sharp echo "export UNIVER_USER_LOGIN="xxx"" >> /etc/profile
    grep "UNIVER_SEARCH_VIDEO" environment-variable.ini >> /etc/profile
fi

I wrote a shell instruction, but whether the variable UNIVER_SEARCH_VIDEO exists or not, it will renew the export UNIVER_USER_LOGIN=" http://127.0.0.1/api/login" instruction

.
Apr.05,2021

I do not recommend storing environment variables used in scripts separately. Put it directly into the script and be self-sufficient. This maximizes the transferability of the script.

if it is an environment variable used by the user, it should be run in interactive mode. For example, various configurations such as rvm, sdkman are placed in ~ / .bashrc (in bash environment) or ~ / .zshrc (in zsh environment), etc.

Menu