From 36bc9165456a7f3c5c53ae51f511869573aba891 Mon Sep 17 00:00:00 2001 From: Kenn Ejima Date: Thu, 13 Sep 2012 15:13:16 -0700 Subject: [PATCH] "gh open" without any args opens up the current repo page --- lib/commands/commands.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/commands/commands.rb b/lib/commands/commands.rb index 8ccb663e..3cf05f08 100644 --- a/lib/commands/commands.rb +++ b/lib/commands/commands.rb @@ -46,6 +46,12 @@ desc 'Open the given user/project in a web browser' usage 'github open [user/project]' command :open do |arg| + if arg.nil? + origin = git('remote -v').split("\n").find{|i| i =~ /^origin/ } + if origin + arg = origin.split(/\s/)[1].sub('git@github.com:','').sub('https://github.com/','').sub('.git','') + end + end helper.open "https://github.com/#{arg}" end