Skip to content

Instantly share code, notes, and snippets.

@math2001
Last active February 1, 2018 22:43
Show Gist options
  • Save math2001/58e241ec9ea004a11be908a13cf8485d to your computer and use it in GitHub Desktop.
Save math2001/58e241ec9ea004a11be908a13cf8485d to your computer and use it in GitHub Desktop.
Open your github repo from the command line

Open the current github repo from the command line

It is very likely that the name of the folder of your project is the name of your github repo. If you run this in a terminal:

git config --global alias.hub "!f () { local REPO; local URL; [[ -f .githubrepo ]] && REPO=\"$(head -n 1 .githubrepo)\" || REPO=\"${PWD##*/}\"; URL=\"https://github.com/math2001/$REPO\"; if [[ \"$1\" == i ]]; then URL=\"$URL/issues\"; elif [[ \"$1\" == s ]]; then URL=\"$URL/settings\"; elif [[ \"$1\" == p ]]; then URL=\"$URL/pulls\"; elif [[ \"$1\" == w ]]; then URL=\"$URL/wiki\"; elif [[ \"$1\" == b ]]; then URL=\"$URL/branches\"; elif [[ \"$1\" == r ]]; then URL=\"$URL/releases\"; elif [[ \"$1\" == 'in' ]]; then URL=\"$URL/issues/new\"; fi; echo \"Opening $URL\"; start \"$URL\"; }; f"

replace math2001 by, you guessed it, your username

you will then be able to do this:

~/AppData/Roaming/Sublime Text 3/Packages/JSONComma → master
λ git hub # opens https://github.com/<your_user_name>/JSONComma

~/AppData/Roaming/Sublime Text 3/Packages/JSONComma → master
λ git hub i # opens https://github.com/<your_user_name>/JSONComma/issues

~/AppData/Roaming/Sublime Text 3/Packages/JSONComma → master
λ git hub p # opens https://github.com/<your_user_name>/JSONComma/pulls

~/AppData/Roaming/Sublime Text 3/Packages/JSONComma → master
λ git hub w # opens https://github.com/<your_user_name>/JSONComma/wiki

~/AppData/Roaming/Sublime Text 3/Packages/JSONComma → master
λ git hub in # opens https://github.com/<your_user_name>/JSONComma/issues/new

~/AppData/Roaming/Sublime Text 3/Packages/JSONComma → master
λ git hub whatever # opens https://github.com/<your_user_name>/JSONComma/whatever

If the folder you're in isn't the name of your repo, you can add a .githubrepo with, on the first line, the name of your repo. Not the URL, just the name:

For example:

st-user-package

And then, instead of using the folder name, it will use st-user-package.

👌 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment