Skip to content

Instantly share code, notes, and snippets.

@davep
Created Oct 16, 2019
Embed
What would you like to do?
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