def record(session_file, shell, prompt, alias, envvar):
    """Record a session file. If no argument is passed, commands are written to
    ./session.sh.

    When you are finished recording, run the "stop" command.
    """
    if os.path.exists(session_file):
        click.confirm(
            f'File "{session_file}" already exists. Overwrite?',
            abort=True,
            default=False,
        )

    secho("We'll do it live!", fg="red", bold=True)
    filename = click.format_filename(session_file)
    secho(f"RECORDING SESSION: {filename}", fg="yellow", bold=True)

    print_recorder_instructions()

    click.pause()
    click.clear()
    cwd = os.getcwd()  # Save cwd

    # Run the recorder
    commands = run_recorder(shell, prompt, aliases=alias, envvars=envvar)

    os.chdir(cwd)  # Reset cwd

    secho("FINISHED RECORDING SESSION", fg="yellow", bold=True)
    secho(f"Writing to {filename}...", fg="cyan")
    with open(session_file, "w", encoding="utf-8") as fp:
        fp.write(HEADER_TEMPLATE.format(shell=shell, prompt=prompt))
        write_directives(fp, "alias", alias)
        write_directives(fp, "env", envvar)
        fp.write("\n")
        fp.write("".join(commands))
        fp.write("\n")

    play_cmd = style(f"doitlive play {filename}", bold=True)
    echo(f"Done. Run {play_cmd} to play back your session.")
Record a session file. If no argument is passed, commands are written to
    ./session.sh.

    When you are finished recording, run the "stop" command.
    
src/doitlive/cli.py