Skip to content

cxa/chatgpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

chatgt

中文

ChatGPT in your terminal.

Installation

Copy chatgpt to a directory that is included in $PATH, like /usr/local/bin. Make sure that:

  1. You have curl and jq installed.
  2. You have set the environment variable export OPENAI_API_KEY="[your key]".

Usage

chatgpt system_message user_message

If only one parameter is passed, it defaults to user_message.

system_message is used to identify the AI role, like "You are a BASH programming expert," and then ask BASH-related questions. Setting system_message is recommended to get more accurate answers.

Tips

You can alias some commands to use a fixed system_message:

alias bashq='chatgpt "You are a BASH programming expert"'
alias tcn='chatgpt "You are a English-to-Chinese technical document translation expert"'

Format Output

If you have formatting requirements for output, you can pipe the output to your defined format command. The following example shows how I use a line-wrapping program (cargo install textwrap-cli) in Rust to format the output.

chatgpt() {
    colw=$(tput cols)
    colw=$(( colw > 80 ? 80 : colw ))
    command chatgpt "$@" | tw -w $colw -e '' -
}

About

ChatGPT in your terminal.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages