This is a small bash/zsh function I made a couple of years ago because I wanted ...
Dr. Juande Santander-Vela @juandesant@mathstodon.xyz
This is a small bash/zsh function I made a couple of years ago because I wanted to be able to automatically open the web page of the forge for the remote. Tested it and it works not just with Github and Gitlab, but also with Codeberg, and I guess any other similar code forge.
```bash
function openremote {
if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
then
open $(git remote -v | grep origin | grep fetch | awk '{print $2}' | sed 's/ssh/https/g')
else
echo "Not inside a git repository."
fi
}
```
You just call it inside of a Git repository, and if there is a remote set, it will use the fetch link to create the web page to open. This works even for ssh remotes.
In Linux or *BSD, you can change `open` for something like `xdg-open` or `exo-open` for a desktop agnostic replacement, or `gnome-open`/`kde-open`, if you use any of those desktop environments.