Skip to content

Instantly share code, notes, and snippets.

@NewAlexandria
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NewAlexandria/e817b6e175e6641fe4d1 to your computer and use it in GitHub Desktop.
Save NewAlexandria/e817b6e175e6641fe4d1 to your computer and use it in GitHub Desktop.
File.open(".vimrc","a") do |f|
f.write File.readlines('.gitmodules')
.map(&:strip)
# remove extras
.reject do |l|
l.scan('[').any? || # submodule defs
l.scan(/^path/).any? || # submodules paths
l.empty? # blank lines
end
# remap URLs to user/repo names
.map do |url|
url
.sub('.git','')
.sub(/url\s*=\s*https:\/\/github.com\//,'')
end
# only 2 things left; comments that need to be in VimL format, and repos for NeoBundle.
.map {|repo| repo[0]=="#" ? repo.gsub('#','"') : "NeoBundle '#{repo}'" }
.unshift("\n")
.join("\n")
do
@NewAlexandria
Copy link
Author

I wrote this for anyone converting their Vim plugin manager, from one that uses submodules, to NeoBundle.

It reads the .gitmodules file and appends the modified output to .vimrc.

There are more-universal things it could do, but I've coded it to handle my situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment