Created
October 16, 2019 08:59
-
-
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
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
############################################################################## | |
# 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