GGistDev

Environment and Profiles

Understand where to configure your shell and how environment variables flow.

Login vs interactive shells

  • Login shell reads: /etc/profile then first of ~/.bash_profile, ~/.bash_login, ~/.profile
  • Interactive non-login shell reads: ~/.bashrc

Recommended: source ~/.bashrc from your ~/.bash_profile so interactive settings apply everywhere.

# ~/.bash_profile
[[ -f ~/.bashrc ]] && . ~/.bashrc

~/.bashrc contents

  • Aliases and functions
  • Prompt (PS1), completion
  • Exports needed for interactive tools

PATH management

export PATH="$HOME/bin:$PATH"

Prepend user bins; avoid overriding system paths.

Environment vs shell variables

  • Shell variable: name=value only in current shell
  • Environment variable: export name=value visible to child processes

Profiles on Linux/macOS

  • System-wide: /etc/profile, /etc/bash.bashrc (Linux), launchd environments (macOS)
  • GUI apps may not inherit your shell env on macOS; use launchctl or .plist overrides, or tools like direnv

Secrets

Do not commit secrets. Load via a manager or .env with tooling. Limit scope and permissions.

Locale and encoding

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Summary

  • Put interactive config in ~/.bashrc, source it from login profiles
  • Export variables to pass to child processes; manage PATH carefully