![image](https://private-user-images.githubusercontent.com/28542963/352774917-b984b06b-6506-4031-848a-d68c164d86fe.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTk4NTEsIm5iZiI6MTcyNDU5OTU1MSwicGF0aCI6Ii8yODU0Mjk2My8zNTI3NzQ5MTctYjk4NGIwNmItNjUwNi00MDMxLTg0OGEtZDY4YzE2NGQ4NmZlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDE1MjU1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYyOTIzYTNlZmIwOGRhZDBmMzRkMTVkZmU5YjIxNjYxOWY0MTA2ZWVmN2E5M2I4OTU1NTIyMTNkY2RlNjQzM2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.q4r90JQX4Xs6574KCoqMLX8oHXOjuH6Qn55w-p28Z_M)
This script helps users query terminal command syntax, interactively decide actions, and even execute terminal commands directly. It leverages OpenAI's GPT model to provide accurate and quick command suggestions.
- Query terminal commands based on natural language input.
- Interactive mode to choose actions like copying commands to clipboard.
- Option to execute commands directly.
- Debug mode for more detailed output.
-
Clone the repository:
git clone https://github.com/EsmaeelNabil/hto cd hto
-
Install dependencies:
bun install
-
Add your OpenAI API Key:
- Create a
.env
file in the root directory of your project in case of development. - Or Add it in your
.zshrc
or.bashrc
or evenexport API_KEY=your_api_key_here
in your terminal before running the script. - To Add your API Key:
API_KEY=your_api_key_here
- Create a
-
generate an executable:
- To generate
hto
in your project directory, run the following command:./release.sh
- To generate
To query terminal commands using natural language input:
./hto "How to list files in macOS"
![image](https://private-user-images.githubusercontent.com/28542963/352774616-aacc7c5a-fe5c-4fcb-8577-d7d27d37d36e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTk4NTEsIm5iZiI6MTcyNDU5OTU1MSwicGF0aCI6Ii8yODU0Mjk2My8zNTI3NzQ2MTYtYWFjYzdjNWEtZmU1Yy00ZmNiLTg1NzctZDdkMjdkMzdkMzZlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDE1MjU1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYyNmI2ZThkOTAxNzczYmI3YWU3N2E3ODE3NTFkMTNjYThhY2Q4MDNkMWMxMTYyNGU5NGJmMDUwZDRlMmYzZDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.-XkqAdFeIATzgcQgEIN_4hklK_jyBBrnQ-0-x9pfRKQ)
For an interactive session where you can choose actions such as copying commands to the clipboard:
./hto -i
Follow the prompts to input your question and select the desired action.
To execute the terminal command suggested by the script:
./hto -e "How to list files in macOS"
For additional debug information:
./hto -d "How to list files in macOS"
To use a specific model, use the -m
key.
![image](https://private-user-images.githubusercontent.com/28542963/352774784-0b9d8f51-13bd-463f-b5fb-d7a05454bb97.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTk4NTEsIm5iZiI6MTcyNDU5OTU1MSwicGF0aCI6Ii8yODU0Mjk2My8zNTI3NzQ3ODQtMGI5ZDhmNTEtMTNiZC00NjNmLWI1ZmItZDdhMDU0NTRiYjk3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDE1MjU1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM1ZjUyYmY2NmU5N2E0M2MyMDFmNDEzNjcwNDdjYmMyYzE5NTc3ZWE4MzllNTk5NDI4ZDc2NDRlNTdmNDYwYWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.0hWuBTyJJmellyBW-OmPZ0tQij8p6x_cQqH4SjF5eEQ)
./hto "How to list directories in Linux" -m "gpt-4o" -d
If you want to try the script in development mode, use bun run main.js
instead of hto
:
bun run main.js "How to list files in macOS"
Feel free to fork the project, open issues, or submit pull requests to improve this project.
This project is licensed under the MIT License.
You can find the latest release here.