Open a file in Github from your command line

How you can use your command line to open a file in Github

I wanted to share a gist that a colleague at ExamTime has written and shared up on Github.

He wanted to be able to quickly get access to a file on Github without wanting to jump around the Github website, so he wrote a script he can run from inside a git repository on your terminal.

If you add it into your bin directory as an executable (or add it into your path or whatever way you crazy kids want to handle it) and call it say repo then you can call the following;

$ repo -f app/controllers/my_awesome_controller.rb

And it will take you to the main branch version of that file, if you want to see another branch then you can specify that as well by typing in;

$ repo -b my_cool_branch -f app/controllers/my_awesome_controller.rb

I am sure plenty of people (including myself) will find this super handy.

Recent posts View all

Rails

Getting Turbolinks to work with Webpack

How to re-add Turbolinks back into a Rails app when moving to Webpack

Rails

How to add Tailwind UI to a Rails project

The steps we went through to set Tailwind UI up on an existing Rails project