#shell #ChatGPT #openai #gpt #bash #openai-api #api-key

bin+lib shell-gpt

直接从您的终端向ChatGPT请求shell脚本、代码或任何内容 🤖🧠👨‍💻

1 个不稳定版本

0.1.1 2023年4月16日
0.1.0 2023年4月16日

#67#gpt

41 每月下载量

MIT 许可证

525KB
432 代码行



ShellGPT


直接从您的终端向ChatGPT请求shell脚本、代码或任何内容 🤖🧠👨‍💻

Cargo Build and Test Downloads Downloads

演示

Demo video

安装

安装后,二进制文件名为 gpt,而不是 shell-gpt

Cargo

cargo install shell-gpt
gpt --help

从源代码

git clone [email protected]:rigwild/shell-gpt-rs.git
cd shell-gpt-rs
cargo install --path .

用法

首次使用时,ShellGPT会提示您输入您的OpenAI API密钥

此密钥将被保存到 ~/.config/shell-gpt-rs,并使用 ChaCha20-Poly1305 加密,以便以后重用。

任何疑问

向ChatGPT提出任何问题。

gpt <any question>

--script

向ChatGPT请求创建脚本,然后如果您想的话可以运行它。您的请求将包括一个预提示

gpt --shell show me the 10 biggest files in the current tree
Asking ChatGPT...

#!/bin/bash
du -ah | sort -rh | head -n 10

Do you want to run this script? (y/N) y

Executing script...

--------------


4.1G    ./target
4.1G    .
3.5G    ./target/debug
2.9G    ./target/debug/deps
588M    ./target/release
488M    ./target/release/deps
387M    ./target/debug/build
241M    ./target/debug/incremental
98M     ./target/release/build
86M     ./target/debug/deps/gpt-54b56efa1b0d0573

--raw

向ChatGPT请求创建脚本,但不显示加载指示器或交互式提示,不运行脚本。

这可以用于将脚本管道到另一个命令。

gpt --shell --raw show me the 10 biggest files in the current tree
du -ah | sort -rh | head -n 10

--clear-config

删除本地配置,包括位于 ~/.config/shell-gpt-rs 的OpenAI API密钥。

gpt --clear-config

帮助信息

gpt --help
Ask ChatGPT for a shell script, code, or anything, directly from your terminal 🤖🧠👨‍💻

Usage: gpt <your_question>

Options:
  -s  --shell           Ask ChatGPT for a shell script                                                  [boolean=false]
      --raw             Only output the script, no spinner or interactive prompt                        [boolean=false]
      --clear-config    Remove local config, including the OpenAI API key at `~/.config/shell-gpt-rs`   [boolean]
  -h, --help            Show help                                                                       [boolean]

Examples:
  gpt is the earth flat?
  gpt --shell show the list of files in the current directory with human-readable file size
  gpt -s find the top 10 biggest files in the current directory
  gpt -s find the top 10 biggest files in the current tree recursive
  gpt --raw --shell find the top 10 biggest files in the current tree recursive
  gpt --raw --shell find the top 10 biggest files in the current tree recursive > 10_biggest_files.sh
  gpt --raw tell me a good joke | curl -X POST -d @- https://example.com/api/jokes

shell-gpt-rs - https://github.com/rigwild/shell-gpt-rs

示例

gpt How to install a package in Arch Linux?
gpt How to create a Rust crate?
gpt --shell show the list of files in the current directory with human-readable file size
gpt -s find the top 10 biggest files in the current tree recursive

# Save the script to a file
gpt --raw --shell find the top 10 biggest files in the current tree recursive > 10_biggest_files.sh

# Generate a joke then post it with curl
gpt --raw tell me a good joke | curl -X POST -d @- https://example.com/api/jokes

许可证

MIT许可证

依赖项

~11–27MB
~404K SLoC