GitHub - alaa-alawi/q: LLM in a Terminal · GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
alaa-alawi
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>4 Commits<br>4 Commits
.gitignore
.gitignore
CHANGELOG.md
CHANGELOG.md
LICENSE
LICENSE
Makefile
Makefile
README.md
README.md
SYSTEM.txt
SYSTEM.txt
q.c
q.c
View all files
Repository files navigation
LLM interleaved with Terminal
A proof of concept of interleaving the terminal/shell with the LLM. so you can do day to day shell commands and if stuck or want more clarification, in the same prompt the users post their question to the LLM, and get answers there, thus no need to hop to the browser. kind of nearby senior who can help clarify or provide examples for what you are trying to do. Examples (after launching it in repl mode with q --repl )
$ q --repl --color
1 $ show the last 100 nginx service logs without paging
2 $ restart nginx and verify it is listening on ports 80 and 443
3 $ list failed systemd units and show commands to inspect each failure
4 $ show disk usage by top-level directories under /var
5 $ find files larger than 1G under /home modified in the last 7 days
6 $ check apt package holds and pending security upgrades
7 $ create a systemd timer that runs /usr/local/bin/backup.sh daily at 02:30
8 $ write an rsync command to mirror /srv/data to backup@example:/backups/data preserving permissions and deleting removed files
9 $ ? top processes by memory with ps, sorted descending
and many others like:
show ufw commands to allow ssh, http, and https then enable the firewall<br>diagnose DNS resolution problems using resolvectl, dig, and systemd-resolved logs<br>show commands to list users with sudo access<br>generate a logrotate config for /var/log/myapp/*.log keeping 14 compressed daily logs<br>check memory pressure and swap usage from the command line<br>show commands to inspect SMART health for /dev/sda
Hope you got the drift. It is rough and rather large with ~7k of vibed code, and I had been using it as a daily driver.
Note that the output of queries will depend on the LLM used.
Sometimes q will be confused with a query for a command (i.e. who or which), usually this can be workaround by Capitalizing the first word of a query.
Still you can use ! to force a shell execution or ? to force a query.
If an LLM was asked for a shell/bash/zsh examples and these were fenced, then these are detected and are numbered from 1 to the last one. you can then type the number followed by dot (i.e. 2.) which will execute it without typing it.
for help use slash command /help which will show other commands.
In summary q is a small vibed (using codex) C CLI named q that sends all command-line arguments as one input1 string to a local OpenAI-compatible Responses API using a Linux sysadmin system prompt. Responses are streamed to stdout as they arrive.
Note that again, this is a proof of concept rather than finished work, and waiting until it is ready will take forever, thus opting to publish the code so other smarter people can have fun and run with it.
Below is the start of LLM generated content
Build
make
For a stripped release binary:
make release
Install to /usr/local/bin by default:
sudo make install
Requires libcurl development headers:
sudo apt install build-essential libcurl4-openssl-dev
Colors can be overridden at compile time with C macros such as Q_COLOR_LLM_TEXT, Q_COLOR_CODE_EMULATOR, Q_COLOR_CODE_TTY, Q_COLOR_PROMPT_LINE_NO, Q_COLOR_EXIT_OK, Q_COLOR_EXIT_FAIL, Q_COLOR_MENU_SELECTED, Q_COLOR_TOOL_CONFIRM, and Q_COLOR_RESET.
Run
Usage:
./q [--repl] [--keep-context] [--record-session] [--resume-session [id|last]] [--list-sessions] [--add-mcp-server url] [--remove-mcp-server name] [--list-mcp-servers] [--llm-timeout seconds] [--llm-turn-limit count] [--api-logging none|query|response|both|path] [--system-prompt-file filepath] [--think-loud] [--color] [query words...]
export OPENAI_API_KEY='your_api_key'<br>./q --repl
For...