Large Language Models

Recording Chat Transcripts

Published 2025-12-13.
Time to read: 1 minutes.

This page is part of the llm collection.

Command-line interface (CLI) chat clients like ollama, ChatGPT, and Mini-Agent are very useful, but most of them suffer from a few serious problems:

  1. They do not provide a way to save a transcript of the entire session.
  2. The scrollback buffer is limited in size. For a chat client, that means you can only see the last few screens of dialog before it is lost forever.
  3. Transcripts cannot be searched or summarized.

This article discusses the record Bash script that provides a universal solution to that problem.

The record Script

record
#!/bin/bash

# Mike Slinn mslinn@mslinn.com

# Default values:
OUTFILE_BASE="chat"
CHAT_COMMAND="mini-agent" # Put your favorite chat command here
# CHAT_COMMAND="ollama run qwen3:4b" # Example of running a ollama model

usage() {
    echo "
Usage: $(basename $0) [-o BASENAME] [-c COMMAND] [COMMAND_ARGS...]

Options:
  -c  Specify the command to run the chat client (default: ${CHAT_COMMAND})
  -o  Specify the base name for the log file (default: ${OUTFILE_BASE})

Example:
  $(basename $0) # Runs the default client with the default output file base name
  $(basename $0) -c 'ollama run qwen3:4b' -o binary_search
  $(basename $0) -c mini-agent -o inspect

You can view the log of the live chat session delayed by a few seconds by using 'tail -F'.
For example:
  tail -F 2025-12-12_20-06-39_chat.log
"
  exit 1
}

while getopts ":o:c:h" opt; do
  case $opt in
    c)
      CHAT_COMMAND="$OPTARG"
      ;;
    o)
      OUTFILE_BASE="$OPTARG"
      ;;
    *)
      usage
      ;;
  esac
done
shift $((OPTIND-1))

if [ -z "$CHAT_COMMAND" ]; then
  echo "Error: You must specify a chat client command using -c."
  usage
fi

LOG_FILE="$(date +\%Y-\%m-\%d_\%H-\%M-\%S)_${OUTFILE_BASE}.log"

if [ "$CHAT_COMMAND" != mini-agent ]; then
  echo "Press Ctrl+D to end the chat and stop recording."
fi

# Execute the script command with the specified chat client command
# The -c option ensures the script terminates when the client terminates
script -a "$LOG_FILE" -c "$CHAT_COMMAND"

echo "Recording finished. Log saved to $PWD/$LOG_FILE"

Help Message

This is the record help message:

Shell
$ record -h
Usage: record [-o BASENAME] [-c COMMAND] [COMMAND_ARGS...] Options: -c Specify the command to run the chat client (default: 'mini-agent') -o Specify the base name for the log file (default: chat) Example: record # Runs the default client with the default output file base name record -c 'ollama run llama3' -o binary_search record -c mini-agent -o inspect You can view the log of the live chat session delayed by a few seconds by using 'tail -F'. For example: tail -F 2025-12-12_20-06-39_chat.log

Usage Examples

Examples of usage are provided in:

You could review the session later by typing:

Shell
$ less 2025-12-12_20-06-39_chat.log

You could also view the log of the live session delayed by a few seconds by using tail -F:

Shell
$ tail -F 2025-12-12_20-06-39_chat.log

This is an easy way to share a chat with an audience. Everyone in the audience would use SSH to connect to the machine running the chat, then they would all use the above tail -F command.

* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.