Created
July 27, 2010 19:29
-
-
Save vanntastic/492727 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 -wKU | |
if ARGV[0].nil? | |
puts " gh_search [name_of_repo]: \n - Copies repo url to clipboard (via pbcopy) if only one repo is found" | |
else | |
search_string = "Searching github for #{ARGV[0]}...." | |
border = "="*search_string.length | |
puts "#{search_string}\n#{border}" | |
res = `gh search #{ARGV[0]}`.split("\n") | |
if res.length == 1 | |
user, repo = res.first.split("/").first, res.first.split("/").last | |
repo_url = "http://github.com/#{user}/#{repo}.git" | |
system("echo #{repo_url} | pbcopy") | |
puts "#{repo_url} has been copied to the clipboard!" | |
else | |
puts "#{res.length} Repositories found!" | |
res.each do |r| | |
puts "- #{r} (gh_search #{r.split('/').last} to copy)" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment