code: def record(session_file, shell, prompt, alias, envvar):
      
      if os.path.exists(session_file):
          click.confirm(
              'File "{0}" already exists. Overwrite?'.format(session_file),
              abort=True,
              default=False,
          )
  
      secho("We'll do it live!", fg="red", bold=True)
      filename = click.format_filename(session_file)
      secho("RECORDING SESSION: {}".format(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("Writing to {0}...".format(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("doitlive play {}".format(filename), bold=True)
      echo("Done. Run {} to play back your session.".format(play_cmd))
docs: Record a session file. If no argument is passed, commands are written to
      ./session.sh.
  
      When you are finished recording, run the "stop" command.