Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/charyan/osh
Ollama Shell Helper (osh) : English to Unix-like Shell Commands translation using Local LLMs with Ollama
https://github.com/charyan/osh
llm ollama python shell unix
Last synced: 18 days ago
JSON representation
Ollama Shell Helper (osh) : English to Unix-like Shell Commands translation using Local LLMs with Ollama
- Host: GitHub
- URL: https://github.com/charyan/osh
- Owner: charyan
- License: mit
- Created: 2024-01-17T09:49:16.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-01-19T07:07:52.000Z (10 months ago)
- Last Synced: 2024-07-31T20:29:49.584Z (3 months ago)
- Topics: llm, ollama, python, shell, unix
- Language: Python
- Homepage:
- Size: 90.8 KB
- Stars: 32
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cli-apps - osh - Ollama Shell Helper (osh): English to Unix-like Shell Commands translation using Local LLMs with Ollama. (<a name="ai"></a>AI / ChatGPT)
- awesome-cli-apps-in-a-csv - osh - Ollama Shell Helper (osh): English to Unix-like Shell Commands translation using Local LLMs with Ollama. (<a name="ai"></a>AI / ChatGPT)
README
# Ollama Shell Helper (osh) : English to Unix-like Shell Commands translation using Local LLMs with Ollama
![screenshot](screenshot.png)
# How it works
The user request is passed to the ollama server along with system information from `uname -a` and the distribution (if running on Linux). The result is displayed in the terminal and asks for confirmation to execute the command.```
usage: osh.py [-h] [-y] [-s] [PROMPT]Get a command for a unix-like shell from a model running with Ollama and execute it
positional arguments:
PROMPToptions:
-h, --help show this help message and exit
-y, --yes Execute the command without asking for confirmation
-s, --system-info Display system info
```# Usage
## Ollama
Install [ollama](https://ollama.ai/)Pull the model:
```
ollama pull mistral
```Start the ollama server:
```
ollama serve
```## OSH
```
python osh.py 'update all packages'```
# Examples with Mistral 7B
```
python osh.py 'replace occurences of "hello" with "h_ello" in abc.txt'perl -pi -e 's/hello/h\_ello/g' abc.txt
``````
python osh.py 'change owner of abc.txt to root'chown root abc.txt
``````
python osh.py 'enable docker at startup'sudo systemctl enable docker.service
sudo systemctl start docker.service
``````
python osh.py 'docker run an ubuntu with terminal attached and port 8080 of the host mapped to 80 of the container'sudo docker run --rm -it -p 8080:80 ubuntu:latest /bin/bash
``````
python osh.py 'add the user johnny with the groups docker, wheel and dev'sudo useradd -m -g wheel -G docker,dev johnny
``````
python osh.py 'download https://something.com/file.html and transform it into a pdf with pandoc'wget -P ~/Downloads "https://something.com/file.html" && \
pandoc -f html -t pdf ~/Downloads/file.html -o ~/Documents/output.pdf
```