Created
May 3, 2024 15:01
-
-
Save peetzweg/36f9a97dd59b3e60b8349d07de90c06b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function repo() { | |
# Save current directory | |
local cwd=$(pwd) | |
# Change to given directory | |
if [[ -n "$1" ]]; then | |
cd $1 | |
fi | |
local remote=$(git config --get remote.origin.url) | |
if [[ -z "$remote" ]]; then | |
echo "Not a git repository" | |
return 1 | |
fi | |
local repo=$(echo $remote | sed 's/.*github.com[:/]\(.*\).git/\1/') | |
local url="https://github.com/${repo}" | |
open $url | |
# Return to original directory | |
cd $cwd | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment