This is an adaptation of https://twitter.com/jasonneylon script.
In the terminal window, you can open your current repo (at the current branch) in your default browser.
My adaptation was adding options to view the commits, branches, pull requests or issues for the repo using one of the additional options (added support for wiki, settings, pulse, graphs, network):
[-h] => View help
[-c] => View commits
[-b] => View branches
[-pr] => View pull requests
[-i] => View issues
[-w] => View wiki
[-s] => View settings
[-p] => View pulse
[-g] => View graphs
[-n] => View network
This is a bash script, so it would be recommended that you include it in your ~/.bashrc (or ~/.bash_profile) file.
Using the command line (as it's generally easier than searching for potentially hidden files):
$ vi ~/.bash_rc- or use your preferred text editor e.g.mate,subletc.- Paste
function gh() { ... }into~/.bashrcfile- If you opted to use
$ vi, you may need to pressato allow you to edit the file
- If you opted to use
- Save
.bashrc(you may also close the file)- If you opted to use
$ vi, save and close the file:ESCand:wq
- If you opted to use
$ source ~/.bashrc- updates the Terminal/Shell with your changes, activating them ready for use
$ ghOpen your repo from the command line$ gh -iView/list helper options$ gh -cOpen your branches Commits from the command line$ gh -bOpen your repo's Branches from the command line$ gh -prOpen your repo's Pull Requests from the command line$ gh -iOpen your repo's Issues from the command line$ gh -wOpen your repo's Wiki from the command line$ gh -sOpen your repo's Settings from the command line$ gh -pOpen your repo's Pulse Activity from the command line$ gh -gOpen your repo's Graphs/Analytics from the command line$ gh -nOpen your repo's Network Graph from the command line
I plan on making some improvements to this script (when I get the time to study bash/github a little more):
- Amend
elif [ "$1" = "-pr" ];to only show Pull Requests merging to/from the current branch
Any thoughts, suggestions or improvements? Let me know https://twitter.com/carmat71
Source: http://jasonneylon.wordpress.com/2011/04/22/opening-github-in-your-browser-from-the-terminal/
N.B.
This script works for most* operating systems, although it does involve editing slightly. The only parts that should need editing are wher you see the command open. This is specific to Mac OS. Other OS's will need to be customised like so:
- Mac
open - Windows
startorcmd /c start - Linux/Unix
xdg-open - Cygwin
cygstart
*Mac OS and MS Windows are the only operating sytems I have been able to test.