Some helper scripts for the day to day work with Ubuntu in WSL2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
688 B

import click
import itertools
import random
import pyperclip
lowers = "abcdefghijklmnopqrstuvwxyz"
uppers = lowers.upper()
decimals = "0123456789"
characters = list(lowers + uppers + decimals)
@click.command()
@click.option("--length", default=16, type=int)
def get_random_password(length=16):
""" generates a random password and copies it to the clipboard """
choice = [random.choice(characters) for i in range(length)]
groups = [iter(choice)] * 4
grouped = ("".join(g) for g in itertools.zip_longest(*groups, fillvalue=""))
password = "-".join(grouped)
pyperclip.copy(password)
click.echo("Copied to clipboard:", err=True)
click.echo(password)