79289916

Date: 2024-12-18 03:38:27
Score: 0.5
Natty:
Report link

I used @chepner answer to make archlinux environment variable (PATH) from .env file. Here is my working code for bash. File: ~/.bashrc

FROMENV=''
  while IFS="=" read -r key value; do
    case "$key" in
      '#'*) ;;
      *)
        echo "Key: $key"
        echo "Value: $value"
        FROMENV+=":$value"
    esac
  done < .env
  
  echo "$FROMENV"
  
  PATH=$PATH$FROMENV

After checking, just comment out the echo. # echo "$FROMENV"

For reference my .env file (both in same dir)

NODEJS=/opt/node-v22.11.0-linux-x64/bin
GO=/home/sud/go/bin
PNPM=/home/sud/.local/share/pnpm
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @chepner
  • Low reputation (0.5):
Posted by: Sudhakar Krishnan