← 返回命令列表

Linux command

sgpt 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Ask a question

sgpt "[How do I list files?]"

Generate shell command

sgpt -s "[list all PDF files]"

Execute shell command

sgpt -se "[find large files]"

Generate code

sgpt -c "[python function to sort list]"

Chat mode

sgpt --chat [session_name] "[message]"

Use specific role

sgpt --role [code] "[question]"

Pipe input

cat [file.txt] | sgpt "[summarize this]"

说明

sgpt (Shell GPT) is a command-line interface for interacting with OpenAI's ChatGPT models, optimized for developer and system administration workflows. It operates in several modes: general queries for quick answers, shell mode (-s) for generating executable commands with explanations, and code mode (-c) for producing programming solutions with automatic language detection. Chat sessions maintain conversation context across multiple invocations, allowing follow-up questions and iterative refinement. Roles customize the AI's behavior for specific tasks, with predefined roles for common scenarios and support for user-defined custom roles. The tool integrates naturally with Unix pipelines, accepting input via stdin to process file contents, command output, or any streamed data through AI analysis. This makes it useful for tasks like summarizing logs, explaining error messages, or generating documentation from code.

参数

-s, --shell
Generate shell command.
-se
Shell and execute.
-c, --code
Generate code.
--chat _NAME_
Chat session.
--role _ROLE_
Use role.
--model _MODEL_
Specify model.
--temperature _TEMP_
Response randomness.
--no-cache
Disable caching.

FAQ

What is the sgpt command used for?

sgpt (Shell GPT) is a command-line interface for interacting with OpenAI's ChatGPT models, optimized for developer and system administration workflows. It operates in several modes: general queries for quick answers, shell mode (-s) for generating executable commands with explanations, and code mode (-c) for producing programming solutions with automatic language detection. Chat sessions maintain conversation context across multiple invocations, allowing follow-up questions and iterative refinement. Roles customize the AI's behavior for specific tasks, with predefined roles for common scenarios and support for user-defined custom roles. The tool integrates naturally with Unix pipelines, accepting input via stdin to process file contents, command output, or any streamed data through AI analysis. This makes it useful for tasks like summarizing logs, explaining error messages, or generating documentation from code.

How do I run a basic sgpt example?

Run `sgpt "[How do I list files?]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -s, --shell do in sgpt?

Generate shell command.