Skip to content

Instantly share code, notes, and snippets.

@kechol
Last active July 10, 2017 03:33
Show Gist options
  • Save kechol/e184a74a6c8b91166df7da5434bba94c to your computer and use it in GitHub Desktop.
Save kechol/e184a74a6c8b91166df7da5434bba94c to your computer and use it in GitHub Desktop.
Generate projects.cson from `ghq list` for Atom project-manager plugin
#!/usr/bin/env ruby
require 'json'
cson = []
del = '/'
begin
ghqlist = `ghq list --full-path`
ghqroot = File.expand_path(`git config --get ghq.root` || '~/.ghq').strip
rescue => e
exit 1
end
ghqlist.split("\n").each do |path|
title = path.gsub(ghqroot, '').split(del)[2..-1].join(del)
cson << { title: title, paths: [path] }
end
puts JSON.pretty_generate(cson)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment