Created
July 16, 2022 21:57
-
-
Save douglascayers/c9599f1713c3874ab79c13fbd8b77779 to your computer and use it in GitHub Desktop.
Bash alias to open a git remote in your browser.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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