Last active
July 10, 2017 03:33
-
-
Save kechol/e184a74a6c8b91166df7da5434bba94c to your computer and use it in GitHub Desktop.
Generate projects.cson from `ghq list` for Atom project-manager plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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