Skip to content

Instantly share code, notes, and snippets.

@douglascayers
Created July 16, 2022 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglascayers/c9599f1713c3874ab79c13fbd8b77779 to your computer and use it in GitHub Desktop.
Save douglascayers/c9599f1713c3874ab79c13fbd8b77779 to your computer and use it in GitHub Desktop.
Bash alias to open a git remote in your browser.
# Opens in a browser the git remote url
# specified by the given remote.
#
# Arguments:
# $1 = git remote name (default is 'origin')
#
# Usage:
# $ openg [remote]
#
# Examples:
# $ openg // opens 'origin' remote url
# $ openg upstream // opens 'upstream' remote url
#
# This is a function instead of a bash alias
# because I need to make use of arguments.
# https://stackoverflow.com/a/7131683/470818
function openg() {
local GIT_REMOTE="${1:-origin}"
local GIT_REMOTE_URL=$(git remote get-url "$GIT_REMOTE")
open $GIT_REMOTE_URL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment