A lightweight command-line shell written in Python. It supports common file and directory operations and suggests corrections when you mistype a command.
- 📁 File & directory operations: create, remove, copy, and move files and folders
- 📂 Navigation: list contents and change directories with
ls,cd, andpwd - 📄 File viewing: display the contents of text files with
cat - 🧠 Smart suggestions: detects typos and suggests the closest valid command
- 🛡️ Safe error handling: clear messages for missing files, permission problems, and invalid operations
- 🐍 Python 3.10 or newer (the code uses
matchstatements) - No third-party dependencies. Only the Python standard library is used.
Clone the repository and move into the project folder:
git clone https://github.com/FarnazZS/simple-shell.git
cd simple-shellRun the shell:
python Shell.pyYou will see a prompt like this:
Welcome to Simple Shell
Type 'exit' to quit
Commands: pwd, ls, cd, touch, ni, mkdir, rm, rmdir, cat, cp, mv, clear, cls, exit
$
| Command | Description | Example |
|---|---|---|
pwd |
Print the current working directory | pwd |
ls [path] |
List files and folders | ls or ls docs |
cd <path> |
Change directory (.. moves up one level) |
cd projects |
touch / ni <file> |
Create an empty file | touch notes.txt |
mkdir <dir> |
Create a directory | mkdir backup |
rm <file> |
Remove one or more files | rm old.txt |
rmdir <dir> |
Remove an empty directory | rmdir backup |
cat <file> |
Display the contents of a text file | cat notes.txt |
cp <src> <dest> |
Copy files or folders | cp a.txt b.txt |
mv <src> <dest> |
Move or rename files | mv a.txt archive/ |
clear / cls |
Clear the terminal screen | clear |
exit |
Quit the shell | exit |
If you mistype a command, the shell suggests a correction:
$ mkdr test
Command 'mkdr' not found. Did you mean 'mkdir'?
Do you want to execute 'mkdir'? (y/n): y
Directory 'test' created successfully
simple-shell/
├── Shell.py
├── requirements.txt
├── .gitignore
├── LICENSE
└── README.md
- 🖥️ Cross-platform
clearcommand (currently uses the Windowsclscommand) - ⬆️ Command history and arrow-key navigation
- 🔤 Support for quoted arguments, so paths with spaces work naturally
- 🔀 Output redirection (
>) and piping (|) - ➕ Additional commands such as
echo,head,tail, andfind - 🎨 Colored output for errors and prompts
- 🧪 Unit tests for all commands
- ❓ A built-in
helpcommand
Contributions are welcome! Feel free to open an issue or submit a pull request.
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m "Add your feature") - Push to the branch (
git push origin feature/your-feature) - Open a pull request
This project is licensed under the MIT License. See the LICENSE file for details.
Farnaz Zarrabi Shirabad
- GitHub: @FarnazZS