#!/usr/bin/env python

import configparser
import re

_CYAN = '\x1b[36m'
_RESET = '\x1b[0m'

def _format_url(url):
    url = re.sub(":", '/', url)
    url = re.sub("^.*@", 'https://', url)
    return url.strip()

def _format_key(key):
    key = re.sub('"', '', key)
    key = re.sub('branch', '', key)
    key = re.sub('remote', '', key)
    return key.strip()

try:
    config = configparser.ConfigParser()
    config.read(".git/config")

    for key in config.keys():
        if not key.startswith('submodule'):
            try:
                url = config.get(key, "url")

                print(f"{_CYAN}{_format_key(key)}{_RESET}: {_format_url(url)}")
            except:
                pass
except:
    print('You are not in the root of a git project')
