Shell Genie 是一种新的命令行工具,可用于以简单的英语询问怎样执行各种任务,并为您提供所需的 shell 命令。 为了生成命令,它使用 OpenAI 的 GPT-3 或 Free Genie,这是一个由 Shell Genie 开发人员提供的免费后端。
一旦 Shell Genie 显示命令,它会询问您是否要运行它。 在执行此操作之前,请确保您了解该命令! 您可以使用 Explain Shell 之类的工具来了解该命令的作用。 此外,最好只将它用于不会破坏计算机的查询/命令。 并非所有命令都能按预期工作,因此使用它需要您自担风险!
这是壳牌精灵在行动:
$ shell-genie ask "find all files that have been changed in the last 3 days from the current directory and subdirectories, with details"
Command: find . -mtime -3 -ls
$ shell-genie ask "use ffmpeg to extract audio from video without re-encoding it"
Command: ffmpeg -i <input_video_file> -vn -acodec copy <output_audio_file>
$ shell-genie ask "replace all instances of ^ with / in all .sh files in the current folder"
Command: sed -i 's/^///g' *.sh
您也可以要求它执行更复杂的命令,只需确保您的查询包含正确的关键字——您的查询非常重要:
$ shell-genie ask "replace all instances of ^ with / in all .php files in the current folder that have been modified in the last 2 days"
Command: find . -name "*.php" -mtime -2 -exec sed -i 's/^///g' {} ;
该工具还可以解释命令,例如 example:
$ shell-genie ask "find all files that have been changed in the last 3 days from the current directory and subdirectories, with details" --explain
Command: find . -type f -mtime -3 -ls
Description: This command will search the current directory and all subdirectories for files that have been modified in the last 3 days. The -type f option specifies that only files should be searched, the -mtime -3 option specifies that only files modified in the last 3 days should be searched, and the -ls option provides detailed information about the files found.
这使我关于怎样查找最近几天或几分钟(以及其他时间)修改的文件的文章变得毫无用处。 哦,好😀️。
我已经使用 Shell Genie 几天了,在大多数情况下,显示的命令都是正确的。 如果不是,通常是由于用户错误——我没有充分解释我想做什么。 不要假设该工具理解您想要它做什么,拼写它! 记住,你是在解释你想对机器做什么,而不是对人做什么。 我还应该提到,我将 Shell Genie 与 OpenAI GPT-3 后端一起使用,而不是 Free Genie 后端。
如果您选择运行命令,并且您使用的是 Free Genie 后端,而不是 OpenAI GPT-3,您可以提供反馈以帮助改进该工具。 请注意,Free Genie 服务器存储请求的命令、操作系统和 shell 版本以改进模型。 此外,服务器不能保证 24/7 的正常运行时间。
还值得一提的是,将 Shell Genie 与 GPT-3 结合使用需要使用 API 密钥,而使用 Free Genie 服务器则不需要。
您可能还喜欢:通过此包装器从命令行使用 ChatGPT
安装和使用壳牌精灵
可以使用 pipx 安装 Shell Genie,pipx 是一种在隔离环境中安装和运行 python 应用程序的工具。 Shell Genie 需要 Python 3.10 或更新版本,因此在继续之前确保您正在使用它(例如,它不适用于 Ubuntu 20.04 或 Debian Bullseye 及更早版本)。
从 Linux 发行版的存储库安装 pipx:
- Debian、Ubuntu 和基于这些的 Linux 发行版(Linux Mint、Elementary OS、Pop!_OS、Zorin OS 等):
sudo apt install pipx
- Fedora:
sudo dnf install pipx
- Arch Linux / Manjaro:
sudo pacman -S python-pipx
- 开放SUSE:
sudo zypper install python-pipx
现在您所要做的就是使用 pipx 安装 Shell Genie:
pipx install shell-genie
Shell Genie 现在应该安装在 ~/.local
(仅供您的用户使用)。 以防万一 ~/.local/bin
在您的 PATH 中不可用,添加它。 pipx 可以自动为你做这件事——运行 pipx ensurepath
,然后打开一个新的终端窗口以使用新的 PATH。
要使用 Shell Genie,您需要对其进行配置。 所以第一次你需要像这样运行它:
shell-genie init
这将提示您选择要使用的后端(OpenAI GPT-3 或 Free Genie)等。如果您选择 OpenAI GPT-3 后端,则需要提供 API 密钥。 你可以通过创建一个 OpenAI 帐户来获得一个,然后访问你的帐户设置并单击 API 密钥。 确保您的 OpenAI 帐户中有足够的积分来使用它。
初始设置完成后,您可以开始使用 Shell Genie,如下所示:
shell-genie ask "<the command you want to run/generate, in plain english>"