One main advantage of a tool like ChatGPT becoming widely available to the public is that you can understand a concept faster because the answer is more digestible than the search engine result.

I spent a few hours this weekend checking out some configuration files on my HOME directory. I have installed a bunch of CLI programs in the last couple of years, but I don’t have a good understanding of how they work. So it’s an excellent opportunity to ask some questions through ChatGPT to help me understand what each command does and whether removing them is safe.

What does export do?

I don’t completely understand the following statements in the .zprofile. I assume that it’s required because the documentation told me to add them.

export N_PREFIX=$HOME/.local/n
export PATH=$N_PREFIX/bin:$PATH
export PATH="$PYENV_ROOT/bin:$PATH"
export PATH="$HOME/.rbenv/bin:$PATH"

The export statement creates a global variable during the active shell session. You can access those variables by prepending the variable with a dollar sign. Since PATH variable is the default global variable for Unix-based operating systems to search for executable files, it’s expected that we have to include our user-installed files in the PATH variable.

export PATH=$N_PREFIX/bin:$PATH

For example, if the initial PATH value is /usr/local/bin, running the above command will expand the $N_PREFIX and $PATH values and prepend them to the previous PATH value separated with a colon. The result will be something like the following.

/Users/username/.local/n/bin:/usr/local/bin

The colon is used as a separator for the shell to search for all the executables in the PATH variable. It’s a common mistake to forget to include :$PATH and cause the shell to be unable to search for the executables that were added before.

You can type export into the shell application to see the list of global variables.

ChatGPT has made it easy for people to understand the basic concept, but it’s still far from being able to write a better email or teaching modern technology that receives an update every year.