title: Conditionally invoking autocmd by file location
body: <p>In an <code>.vimrc</code> file, is it possible to only execute an autocmd if the file is loaded from a particular directory? </p>
  
  <p>In MacVim, i have a line of code in my <code>.vimrc</code> which automatically cds to the directory that contains the file i am editing - however it causes an error when i access the git files that :Gedit creates (vim package <em>fugitive</em>). </p>
  
  <p>The autocmd is:</p>
  
  <pre><code>autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')
  </code></pre>
  
  <p>The error is: </p>
  
  <pre><code>Error detected while processing BufEnter Auto commands for "*":
  </code></pre>
  
  <p>From <code>:echo expand("%")</code> it is clear that Fugitive creates paths that begin with <code>fugitive:///</code>, so i am trying to figure out how to test if the first 12 characters of a file's path == <code>fugitive:///</code></p>