Skip to content

Instantly share code, notes, and snippets.

@davep
Created October 16, 2019 08:59
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 davep/3bac3b30e45a3560c265150e609219db to your computer and use it in GitHub Desktop.
Save davep/3bac3b30e45a3560c265150e609219db to your computer and use it in GitHub Desktop.
Quick and simple fish function to open a current repo's "forge" in the web browser
##############################################################################
# Attempt go visit the origin hub for the current repo.
function gh -d "Visit the repo in its origin hub"
# Check that there is some sort of origin.
set origin (git config --get remote.origin.url)
# If we didn't get anything...
if not test "$origin"
# ...complain and exit.
echo "This doesn't appear to be a git repo with an origin"
return 1
end
# Open in the browser.
open "https://"(string replace ":" "/" (string replace -r '\.git$' "" (string split "@" $origin)[ 2 ]))
end
### gh.fish ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment