Skip to content

Instantly share code, notes, and snippets.

@douglascayers
Last active June 29, 2025 02:04
Show Gist options
  • 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.
#
# $1 = git remote name (default is 'origin')
#
# 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")
# Remove username from URL (e.g., https://[email protected] -> https://github.com)
GIT_REMOTE_URL=$(echo "$GIT_REMOTE_URL" | sed 's|https://[^@/]*@|https://|')
open $GIT_REMOTE_URL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment