Resuming ChatGPT chats in CLI

I have issued an update to my CLI ChatGPT Client (see when I first announced it) so that you can now resume conversations. Here is the new --help output (I personally have an alias cgt=path/to/chat.php to have it quickly available):

Usage: chat.php [-l] [-r [number]] [-s system_prompt] [conversation_input]

Options:
  -l                 Resume last conversation.
  -r [number]        Resume a previous conversation and list 'number' conversations (default: 10).
  -s [system_prompt] Specify a system prompt preceeding the conversation.

Arguments:
  conversation_input  Input for the first conversation.

Notes:
  - To input multiline messages, send an empty message.
  - To end the conversation, enter "bye".

Example usage:
  chat.php -l
    Resumes the last conversation.

  chat.php -r 5
    Resume a conversation and list the last 5 to choose from.

  chat.php -s "Only respond in emojis"
    Have an interesting conversation 🙂

  chat.php Tell me a joke
    Starts a new conversation with the given message.

The CLI client uses a streaming response, so you can watch as it generates your answer.

The resuming functionaliy also changed re-arranges the history in the chat cli folder to a structure chats/%Y/%M/history.%U.txt (with %Y being a 4-digit year, %M a two-digit month and %U the unix timestamp when it was started). The prompt is readline compatibly with a history file so that you can quickly reuse previous questions. You can avoid something to be added to history by prepending it with whitespace.

chat.php -l will quickly resume the last conversation but you can also resume other ones:

$ cgt -r 3                                                                                                                                                     Resuming a conversation. Please choose one: 

1) is there an alternative to the logwatch program that can send daily e-mails with reports on log file (1 answer, 248 words)

2) please give me javascript that restarts a video when i click on it (2 answers, 237 words)

3) does a one-letter domain like w.org (specifically) cost more than other .org domains? (3 answers, 253 words)

Please enter the number of the conversation you want to resume (m for more):

To me, it is very powerful to have ChatGPT available in the CLI since I always have a terminal open. Keeping searchable local history is also something that I like for later (offline) reference.

1 thought on “Resuming ChatGPT chats in CLI

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.