Skip to content

Instantly share code, notes, and snippets.

Created November 11, 2014 11:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Initialize .idea/vcs.xml file with all Git or Mercurial repos below current directory
#!/usr/bin/env php
print <<<HEAD
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(".", RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
$paths = array($root);
foreach ($iter as $path => $dir) {
if ($dir->isDir() && preg_match('_^\.(/(?:.*))?/\.(git|hg)$_', $path, $matches)) {
print ' <mapping directory="$PROJECT_DIR$'.$matches[1].'" vcs="'.($matches[2] == 'hg' ? 'hg4idea' : 'Git').'" />' . "\n";
print <<<END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment