title: creating aliases with for loop (bash_profile)
body: <p>I am trying to create a for loop in my .bash_profile to loop through all directories in my github folder and create an alias to open then in a project workspace.</p>
  
  <p>I have a working script below, however each of the aliases gets bound to the last result.</p>
  
  <p>e.g. if the directory contains:
  dir1
  dir2
  dir3</p>
  
  <p>the final aliases look like this:</p>
  
  <pre><code>op_dir1='cd ~/Documents/GitHub/dir3 &amp;&amp; open . &amp;&amp; atom .' 
  op_dir2='cd ~/Documents/GitHub/dir3 &amp;&amp; open . &amp;&amp; atom .'
  op_dir3='cd ~/Documents/GitHub/dir3 &amp;&amp; open . &amp;&amp; atom .'
  </code></pre>
  
  <p>Here is the initial code:</p>
  
  <pre><code># Git Directories Init
  for d in ~/Documents/GitHub/*
  do
      echo ${d##*/} &amp;&amp; alias op_${d##*/}='cd $d &amp;&amp; open . &amp;&amp; atom .'
  done
  </code></pre>