title: How to write a bash script to set global environment variable?
body: <p>Recently I wrote a script which sets an environment variable, take a look:</p>
  
  <pre><code>#!/bin/bash
  
  echo "Pass a path:"
  read path
  echo $path
  
  defaultPath=/home/$(whoami)/Desktop
  
  if [ -n "$path" ]; then
      export my_var=$path
  else
      echo "Path is empty! Exporting default path ..."
      export my_var=$defaultPath
  fi
  
  echo "Exported path: $my_var"
  </code></pre>
  
  <p>It works just great but the problem is that <code>my_var</code> is  available just locally, I mean in console window where I ran the script. </p>
  
  <p>How to write a script which allow me to export <strong>global</strong> environment variable which can be seen everywhere?</p>