PyTerm is a beginner-friendly Python-based terminal emulator that replicates the behavior of a Unix-like shell. It supports common file and directory operations, command history, auto-completion, natural language queries (via GPT), and optional system monitoring.
This project is ideal for learning how shells work internally while practicing Python file system operations, subprocess management, and basic AI integration.
- File & Directory Commands:
ls
,pwd
,cd
,mkdir
,rm
,cat
,touch
,cp
,mv
- Utility Commands:
echo
,clear
,whoami
,date
,uptime
- Session Management:
history
,help
,exit
/quit
- Optional Monitoring (requires
psutil
):cpu
,mem
- Natural Language Queries: Type
nl: <your request>
to translate into a shell command using GPT (requires API key) - Auto-completion & History: Supports tab-completion and command history via
readline
-
Clone this repository:
git clone https://github.com/yourusername/pyterm.git cd pyterm
-
(Optional) Create a virtual environment:
python -m venv venv source venv/bin/activate # Linux/macOS venv\Scripts\activate # Windows
-
Install dependencies:
pip install -r requirements.txt
If you want system monitoring commands (
cpu
,mem
):pip install psutil
Run the terminal with:
python pyterm.py
Example session:
PyTerm> pwd
/home/user
PyTerm> mkdir test_folder
PyTerm> cd test_folder
PyTerm> touch file.txt
PyTerm> echo "hello" > file.txt
PyTerm> cat file.txt
hello
PyTerm> history
PyTerm> nl: create a folder called logs
[nl ->] mkdir logs
--no-readline
: Disable readline (auto-completion/history)--history-file <path>
: Specify a custom history file path
pyterm/
├── pyterm.py # Main terminal implementation
├── requirements.txt # Dependencies list
└── README.md # Project documentation
- Python 3.7+
psutil
(optional, for monitoring)openai
(optional, for GPT natural language commands)
- Web-based UI (Flask/FastAPI)
- Sandbox execution environment for safety
- More advanced AI-based natural language support
MIT License © 2025