Skip to content

Instantly share code, notes, and snippets.

@peetzweg
Created May 3, 2024 15:01
Show Gist options
  • Save peetzweg/36f9a97dd59b3e60b8349d07de90c06b to your computer and use it in GitHub Desktop.
Save peetzweg/36f9a97dd59b3e60b8349d07de90c06b to your computer and use it in GitHub Desktop.
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