mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-21 02:10:11 +08:00
commit
9fa7e8177b
@ -1,158 +0,0 @@
|
||||
[#]: subject: "Generate Linux Commands from English Text Using ChatGPT AI"
|
||||
[#]: via: "https://itsfoss.com/linux-terminal-ai/"
|
||||
[#]: author: "Sreenath https://itsfoss.com/author/sreenath/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
Generate Linux Commands from English Text Using ChatGPT AI
|
||||
======
|
||||
|
||||
Even expert Linux users don't remember all the Linux commands and their options. It's not possible for us humans.
|
||||
|
||||
But what about the machine? Especially the AI-powered machine?
|
||||
|
||||
Imagine if you could 'order' your terminal to 'show all files under 100 MB in size that were modified in last 12 hours'. Sure, you can 'order' it using the Linux commands but what about interacting with in plain English?
|
||||
|
||||
Thanks to the advancement of AI, it is actually possible. Here's an example of automatically generating the Linux command to show all the files smaller than 10 KB in the present directory.
|
||||
|
||||
![Shell Genie AI assistent in Linux terminal][1]
|
||||
|
||||
The tool I am using is called [Shell Genie][2]. It is a command-line tool that lets you interact with the terminal in plain English.
|
||||
|
||||
It can generate commands, run the commands (if you want to), and it can also explain the generated commands to you.
|
||||
|
||||
![Shell Genie explain commands][3]
|
||||
|
||||
### Features of Shell-Genie
|
||||
|
||||
- Convert plain English to Linux Commands.
|
||||
- Provides an openAI gpt3 backend that requires an API key from openAI and a free-genie backend that is free to use.
|
||||
- Prompt with an option to run the command you asked for.
|
||||
- Explains the generated commands.
|
||||
|
||||
### Install Shell Genie
|
||||
|
||||
Shell-genie is not available in the default repositories of any distro. You can install it using `pipx`.
|
||||
|
||||
In order to install, you need to have Python 3.10+ and Pip installed. You can refer to our article on [how to install pip in Ubuntu and other Linux distributions][4].
|
||||
|
||||
Once `pip` is installed, install `pipx` with the following command:
|
||||
|
||||
```
|
||||
python3 -m pip install --user pipx
|
||||
python3 -m pipx ensurepath
|
||||
```
|
||||
|
||||
![An SVG animation showing pipx Installation steps][5]
|
||||
|
||||
Now, restart the terminal and install shell-genie by running:
|
||||
|
||||
```
|
||||
pipx install shell-genie
|
||||
```
|
||||
|
||||
This may show an error or the need for a dependency.
|
||||
|
||||
![A dependency installation to install the shell-geie properly][6]
|
||||
|
||||
Run the command that is prompted to install the required dependency. In my case:
|
||||
|
||||
```
|
||||
sudo apt install python3.10-venv
|
||||
```
|
||||
|
||||
After this, run the `shell-genie` install command once more, and it will be installed.
|
||||
|
||||
![The steps showing the installation of shell-genie][7]
|
||||
|
||||
Once installation is complete, run the following:
|
||||
|
||||
```
|
||||
shell-genie init
|
||||
```
|
||||
|
||||
This will ask you to select the backend, either openAI or free-genie. If you have [openAI API][8], you can choose that or stay with the free-genie.
|
||||
|
||||
🚧
|
||||
|
||||
free-genie backend may not work always, because it is hosted by the developer, and he cautions of possible outages.
|
||||
|
||||
It will then ask permission to report feedback. Decide on that with a `y/n`.
|
||||
|
||||
![Run shell-genie init commad to set up the shell-genie properly][9]
|
||||
|
||||
You are ready to go now.
|
||||
|
||||
### Working with Shell-genie
|
||||
|
||||
🚧
|
||||
|
||||
If you are going to experiment, try not to use commands with sudo or remove files. Don't put your machine in the hands of a machine.
|
||||
|
||||
As said above, shell-genie provides two modes for working.
|
||||
|
||||
- Get command from plain English
|
||||
- Get command explanation
|
||||
|
||||
#### Get Linux commands from plain English
|
||||
|
||||
You can use shell-genie's `ask` option to get commands from plain English. For eg.
|
||||
|
||||
```
|
||||
shell-genie ask "Display only the folders of this directory"
|
||||
```
|
||||
|
||||
This will display the proper command, and prompt us to run the command or not.
|
||||
|
||||
![The working of shell-genie, that will print the required command from the provided plain text description. Also propt the user to execute the same or not][10]
|
||||
|
||||
#### Get Linux commands with explanation
|
||||
|
||||
You can use shell genie to explain some commands that you want to run.
|
||||
|
||||
```
|
||||
shell-genie ask "display all files smaller than 10kb in here" --explain
|
||||
```
|
||||
|
||||
The above command will first display the required command and explains it and then prompts the user to execute it or not.
|
||||
|
||||
![The explain mode in shell-genie, where it will explain the command that was asked in the form of plain english and then prompts the user to execute it or not][11]
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
There are tools like [Explain Shell][12] that (try to) explain the Linux commands. But this Shell genie takes it to the next level by generating commands from plain English.
|
||||
|
||||
Of course, you cannot rely on artificial intelligence blindly. If you are familiar with the Linux commands a little, you can use Shell Genie to generate commands for your purpose. You won't have to struggle with the man pages or various websites.
|
||||
|
||||
It sorts of helps you do things faster in the terminal and also makes you less knowledgeable. Why? Because the more you rely on it, the less you will learn on your own.
|
||||
|
||||
That's what I think. Feel free to agree or disagree with me in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/linux-terminal-ai/
|
||||
|
||||
作者:[Sreenath][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/sreenath/
|
||||
[b]: https://github.com/lkxed/
|
||||
[1]: https://itsfoss.com/content/images/2023/04/shell-genie.png
|
||||
[2]: https://github.com/dylanjcastillo/shell-genie?ref=itsfoss.com
|
||||
[3]: https://itsfoss.com/content/images/2023/04/shell-genie-explain.png
|
||||
[4]: https://itsfoss.com/install-pip-ubuntu/
|
||||
[5]: https://itsfoss.com/content/images/2023/03/install-pipx.svg
|
||||
[6]: https://itsfoss.com/content/images/2023/03/needs-extensions.png
|
||||
[7]: https://itsfoss.com/content/images/2023/03/install-shell-genie.svg
|
||||
[8]: https://openai.com/product?ref=itsfoss.com
|
||||
[9]: https://itsfoss.com/content/images/2023/03/shell-genie-init.svg
|
||||
[10]: https://itsfoss.com/content/images/2023/03/shell-gen.svg
|
||||
[11]: https://itsfoss.com/content/images/2023/03/shell-genie-explain-action.svg
|
||||
[12]: https://explainshell.com/?ref=itsfoss.com
|
@ -0,0 +1,158 @@
|
||||
[#]: subject: "Generate Linux Commands from English Text Using ChatGPT AI"
|
||||
[#]: via: "https://itsfoss.com/linux-terminal-ai/"
|
||||
[#]: author: "Sreenath https://itsfoss.com/author/sreenath/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
使用 ChatGPT AI 从英文文本生成 Linux 命令
|
||||
======
|
||||
|
||||
即使是专家级的 Linux 用户也不记得所有的 Linux 命令和它们的选项。这对我们人类来说是不可能的。
|
||||
|
||||
但是机器呢? 尤其是人工智能驱动的机器?
|
||||
|
||||
想象一下,如果你可以“命令”你的终端“显示过去 12 小时内修改过的所有小于 100 MB 的文件”。当然,你可以使用 Linux 命令“命令”它,但是用普通的英语进行交互呢?
|
||||
|
||||
由于人工智能的进步,这实际上是可能的。下面是自动生成 Linux 命令以显示当前目录中所有小于 10 KB 的文件的示例。
|
||||
|
||||
![Shell Genie AI assistent in Linux terminal][1]
|
||||
|
||||
我使用的工具叫做 [Shell Genie][2]。它是一个命令行工具,可让你以普通的英语与终端进行交互。
|
||||
|
||||
它可以生成命令、运行命令(如果需要),还可以向你解释生成的命令。
|
||||
|
||||
![Shell Genie explain commands][3]
|
||||
|
||||
### Shell-Genie 的特点
|
||||
|
||||
- 将普通英语转换为 Linux 命令。
|
||||
- 提供一个需要 openAI 的 API 密钥的 openAI gpt3 后端和一个可以免费使用的 free-genie 后端。
|
||||
- 提示一个选项以运行你要求的命令。
|
||||
- 解释生成的命令。
|
||||
|
||||
### 安装 Shell Genie
|
||||
|
||||
Shell-genie 在任何发行版的默认仓库中都不可用。你可以使用 `pipx` 安装它。
|
||||
|
||||
为了安装,你需要安装 Python 3.10+ 和 Pip。你可以参考我们关于[如何在 Ubuntu 和其他 Linux 发行版中安装 pip][4] 的文章。
|
||||
|
||||
安装 `pip` 后,使用以下命令安装 `pipx`:
|
||||
|
||||
```
|
||||
python3 -m pip install --user pipx
|
||||
python3 -m pipx ensurepath
|
||||
```
|
||||
|
||||
![An SVG animation showing pipx Installation steps][5]
|
||||
|
||||
现在,重启终端并运行以下命令安装 shell-genie:
|
||||
|
||||
```
|
||||
pipx install shell-genie
|
||||
```
|
||||
|
||||
这可能显示错误或需要依赖项。
|
||||
|
||||
![A dependency installation to install the shell-geie properly][6]
|
||||
|
||||
运行提示的命令来安装所需的依赖。在我的例子中:
|
||||
|
||||
```
|
||||
sudo apt install python3.10-venv
|
||||
```
|
||||
|
||||
之后,再次运行 `shell-genie` 安装命令,就可以安装了。
|
||||
|
||||
![The steps showing the installation of shell-genie][7]
|
||||
|
||||
安装完成后,运行以下命令:
|
||||
|
||||
```
|
||||
shell-genie init
|
||||
```
|
||||
|
||||
这将要求你选择后端,openAI 或 free-genie。如果你有 [openAI API][8],你可以选择它或继续使用 free-genie。
|
||||
|
||||
🚧
|
||||
|
||||
free-genie 后端可能并不总是工作,因为它由开发人员托管,他警告可能会中断。
|
||||
|
||||
然后它将请求允许报告反馈。用 `y/n` 来决定。
|
||||
|
||||
![Run shell-genie init commad to set up the shell-genie properly][9]
|
||||
|
||||
现在就可以使用了
|
||||
|
||||
### 使用 Shell-genie
|
||||
|
||||
🚧
|
||||
|
||||
如果你要进行实验,请尽量不要使用带有 sudo 或删除文件的命令。不要将你的机器交到机器手中。
|
||||
|
||||
如上所述,shell-genie 提供了两种工作模式。
|
||||
|
||||
- 从普通的英语获取命令
|
||||
- 获取命令解释
|
||||
|
||||
#### 从普通英语中获取 Linux 命令
|
||||
|
||||
你可以使用 shell-genie 的 `ask` 选项从普通的英语中获取命令。例如:
|
||||
|
||||
```
|
||||
shell-genie ask "Display only the folders of this directory"
|
||||
```
|
||||
|
||||
这将显示正确的命令,并提示我们是否运行该命令。
|
||||
|
||||
![The working of shell-genie, that will print the required command from the provided plain text description. Also propt the user to execute the same or not][10]
|
||||
|
||||
#### 获取带解释的 Linux 命令
|
||||
|
||||
你可以使用 shell genie 来解释你要运行的一些命令。
|
||||
|
||||
```
|
||||
shell-genie ask "display all files smaller than 10kb in here" --explain
|
||||
```
|
||||
|
||||
上面的命令首先会显示需要的命令并进行解释,然后提示用户是否执行。
|
||||
|
||||
![The explain mode in shell-genie, where it will explain the command that was asked in the form of plain english and then prompts the user to execute it or not][11]
|
||||
|
||||
### 总结
|
||||
|
||||
有像 [Explain Shell][12] 这样的工具(试图)解释 Linux 命令。但是这个 Shell genie 通过从普通的英语生成命令将它提升到一个新的水平。
|
||||
|
||||
当然,不能一味依赖人工智能。如果你对 Linux 命令有一定的了解,可以使用 Shell Genie 生成适合你的命令。你不必为手册页或各种网站而苦恼。
|
||||
|
||||
它可以帮助你在终端中更快地做事,也可以减少你的知识储备。为什么? 因为你越依赖它,你自己学的就越少。
|
||||
|
||||
这就是我所想的。请随意在评论中同意或不同意我的观点。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/linux-terminal-ai/
|
||||
|
||||
作者:[Sreenath][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/sreenath/
|
||||
[b]: https://github.com/lkxed/
|
||||
[1]: https://itsfoss.com/content/images/2023/04/shell-genie.png
|
||||
[2]: https://github.com/dylanjcastillo/shell-genie?ref=itsfoss.com
|
||||
[3]: https://itsfoss.com/content/images/2023/04/shell-genie-explain.png
|
||||
[4]: https://itsfoss.com/install-pip-ubuntu/
|
||||
[5]: https://itsfoss.com/content/images/2023/03/install-pipx.svg
|
||||
[6]: https://itsfoss.com/content/images/2023/03/needs-extensions.png
|
||||
[7]: https://itsfoss.com/content/images/2023/03/install-shell-genie.svg
|
||||
[8]: https://openai.com/product?ref=itsfoss.com
|
||||
[9]: https://itsfoss.com/content/images/2023/03/shell-genie-init.svg
|
||||
[10]: https://itsfoss.com/content/images/2023/03/shell-gen.svg
|
||||
[11]: https://itsfoss.com/content/images/2023/03/shell-genie-explain-action.svg
|
||||
[12]: https://explainshell.com/?ref=itsfoss.com
|
Loading…
Reference in New Issue
Block a user