import shutil


def get_terminal_width(width_limit):
    """Return the width of current open terminal."""
    try:
        return shutil.get_terminal_size().columns
    except AttributeError:
        # When this function is invoked through piping, sometimes it throws AttributeError.
        return width_limit