Post

Giving AI Total Access To Bash

I decided to experiment with giving a language model control over my Bash CLI. Here’s what I aimed to achieve:

  • Objective: Host and run a local LLM to build a Python script that can serve and execute commands and outputs.
  • Setup:
    • I chose LM Studio for its ease of setup.
    • Set up a server and configured access via WSL so my VSCode environment could reach the API endpoint.
  • Model Testing:

You can check out my Python code here: BASHLLM.

  • If you have any suggestions for improvements, feel free to let me know or reach out. I plan to keep updating the project as I continue refining the code.

You can see the base function is working, but needs plenty of debugging:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
sudo python3 main.py
Enter the task you want to perform: tell my pc to do something cool but keep it a simple default command
echo "Something cool!" | speakup -d pulseaudio
[Executing Command]: echo "Something cool!" | speakup -d pulseaudio
Executing command: echo 'y' | echo "Something cool!" | speakup -d pulseaudio

[Bash Output]:
Error: /bin/sh: 1: speakup: not found


DONE. The requested command 'speakup' is not installed on this system, so no action will be taken. You can try running a different command such as 'echo "Hello World!"' or 'cls' if you are on Windows.echo "Have a nice day!" | speakup
[Executing Command]: echo "Have a nice day!" | speakup
Executing command: echo 'y' | echo "Have a nice day!" | speakup

[Bash Output]:
Error: /bin/sh: 1: speakup: not found


DONEecho "I'm just a humble shell, I can only echo what you tell me!"
[Executing Command]: echo "I'm just a humble shell, I can only echo what you tell me!"
Executing command: echo 'y' | echo "I'm just a humble shell, I can only echo what you tell me!"

[Bash Output]:
Im just a humble shell, I can only echo what you tell me!


echo "Hello, World!"
DONE echo "Something cool is happening!"
[Executing Command]: echo "Something cool is happening!"
Executing command: echo 'y' | echo "Something cool is happening!"

[Bash Output]:
Something cool is happening!


echo "Something cool is happening!"
DONE echo "Something cool happened!"
[Executing Command]: echo "Something cool happened!"
Executing command: echo 'y' | echo "Something cool happened!"

[Bash Output]:
Something cool happened!
This post is licensed under Apache License 2.0 by the author.