Generate commands faster than ever before. Nlp-to-zsh is a cutting-edge tool that seamlessly integrates Natural Language Processing (NLP) services, like OpenAI's ChatGPT, with the Zsh command line. It allows users to type commands in plain English and receive command line suggestions, enhancing the user experience and efficiency.
Use at Your Own Risk. This tool is provided without guarantees or warranty. It sends data from the command line buffer to OpenAI or other NLP services. Note that the commands generated may not always work as expected and could potentially cause harm to your system resulting in data loss. Please proceed with caution and at your own risk. I highly recommend using it in a virtual environment first.
Type what you want to do in plain English and press Ctrl+G
. Choose from the listed options, and the command will magically appear in your command line buffer.
Nlp-to-zsh is fine-tuned and tested primarily for GNU/Linux systems. MacOS users might experience certain limitations.
- Install Dependencies: Ensure
zsh
,python
, andfzf
are installed on your system (using eitherbrew
orpacman
) - Python Requirements: Install the Python dependencies. For this on macOS I'm using a venv because i did not want to force an install gloablly and risk uninteded side effects. For that I ran
python3 -m vnev ./
in the project directory and thensource bin/activate
andpip install -r requirements.txt
. If you're on Arch Linux you can alsosudo pacman -S python-openai
which will install the dependecy gloabally. Check the older commits of this repo of just modify nlp-to.zsh to use the global python version. - Script Installation:
cp ask_gpt.py /usr/local/bin/ && chmod +x /usr/local/bin/ask_gpt.py
(only run this if you're using Arch linux method other wise just give the python script permissionschmod +x ask_gpt.py
and for both macOs and Arch linuxcp nlp-to.zsh /usr/local/bin/ && chmod +x /usr/local/bin/nlp-to.zsh
. You may need to use elevated permissions with thesudo
command. - OpenAI Setup: Obtain an API key from OpenAI, and fine-tune a model with provided data
linux-guru.jsonl
(I used gpt3-turbo with great results). Take note of the model name and api key. - Shell Integration: Append the file
~/.zshrc
with the following lines
source /usr/local/bin/nlp-to.zsh
export OPENAI_API_KEY='your_key_here'
export OPENAI_MODEL_NAME='your_model_here'
export $NLP_TO_ZSH_PATH='path/to/project/directory'
- Open new shell: Open a new instance of
zsh
or source with this command:. .zshrc
orsource ~/.zshrc
.
- Built-in automated testing environment allowing users to quickly sandbox commands.
- Support for multiple APIs for quickly accessing various models.
- Support for locally hosted models.
- Enhanced fine-tuning datasets and models.
- Caching mechanism for previous results
When I first began using Linux, learning the Linux command line was often sifting through Stackoverflow posts, man pages, and blog posts. I remember dreaming I could use natural language to quickly reference commands or write simple scripts. Modern technology makes this possible. I hope this project is a great tool for you to learn the command line quickly and effectively.
Developed by myself. All contributions are deeply appreciated.
Enjoy using nlp-to-zsh!