Standard config files to save PATH settings for shell scripting

These are the standard config files that save PATH settings for shell scripting. 

There is an appropriate Stackoverflow entry: What’s the difference between .bashrc, .bash_profile, and .environment?

1. Bash Profile

nano ~/.bash_profile
  • Example content:
#-------------------
# Java settings
#-------------------
# export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
# SWITCH TO JAVA VERSION 11
export JAVA_HOME=`/usr/libexec/java_home -v 11`
#-------------------
# Manage Python versions with 'pyenv'
eval "$(pyenv init -)"
#-------------------
# Podman  settings
#-------------------
#alias docker=podman
#------------------
# VS Code Settings
#------------------
export MY_VS_CODE_BIN="/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
export PATH=$PATH:$MY_VS_CODE_BIN
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/xx/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/xx/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/xxx/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

2. Z Profile

nano ~/.zshrc
  • Example content:
# ----------------------------
#  Configuration for different Python versions
# ----------------------------
eval "$(pyenv init -)"
#-------------------
# Java settings
#-------------------
# export PATH="/usr/local/opt/openjdk@8/bin:$PATH"
# SWITCH TO JAVA VERSION 8
# export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
# SWITCH TO JAVA VERSION 11
export JAVA_HOME=`/usr/libexec/java_home -v 11`
#-------------------
# Podman  settings
#-------------------
#alias docker=podman
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/thomassuedbroecker/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/thomassuedbroecker/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/thomassuedbroecker/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/thomassuedbroecker/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

I hope this was useful to you, and let’s see what’s next?

Greetings,

Thomas

#bash, #shellscripting, #zsh, #cheatsheet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

%d bloggers like this: