def shorten_url(url, cols, shorten):
    """Shorten long URLs to fit on one line.

    """
    cols = (cols - 6) * 0.85
    if shorten is False or len(url) < cols:
        return url
    split = int(cols * 0.5)
    return url[:split] + '...' + url[-split:]
