https://github.com/saadarazzaq/command-shell
Command Shell implemented in Python with important functionalities 🐚🐍
https://github.com/saadarazzaq/command-shell
cli cmd command-line-interface command-shell documentation python
Last synced: about 1 year ago
JSON representation
Command Shell implemented in Python with important functionalities 🐚🐍
- Host: GitHub
- URL: https://github.com/saadarazzaq/command-shell
- Owner: SaadARazzaq
- Created: 2024-06-16T20:56:31.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-16T21:03:02.000Z (almost 2 years ago)
- Last Synced: 2025-01-23T16:14:20.995Z (over 1 year ago)
- Topics: cli, cmd, command-line-interface, command-shell, documentation, python
- Language: Python
- Homepage: https://www.youtube.com/watch?v=I4EWvMFj37g
- Size: 148 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Command Shell
## Overview
This Python-based Command Shell is a simple CLI (Command Line Interface) application that mimics basic functionalities of a typical shell. It allows users to navigate directories, list contents, execute external commands, and customize the shell prompt.
## Features
- Change directory (`cd`)
- List directory contents (`ls`)
- Execute external commands
- Exit the shell (`exit`)
- Customize the shell prompt (`prompt`)
## Requirements
- Python 3.x
## Installation
1. Ensure you have Python 3.x installed on your system.
2. Download or clone the shell script to your local machine.
## How to Use
1. Open your terminal or command prompt.
2. Navigate to the directory where the script is located.
3. Run the script using Python:
```sh
python shell.py
```
## Commands
### `cd `
- Change the current working directory.
- Example:
```sh
cd /path/to/directory
```
### `ls [directory]`
- List the contents of the specified directory. If no directory is specified, it lists the contents of the current directory.
- Example:
```sh
ls /path/to/directory
```
### `exit`
- Exit the shell.
### `prompt `
- Customize the shell prompt format.
- Placeholders:
- `$PWD$`: Current working directory
- `$HOME$`: Home directory
- Example:
```sh
prompt MyShell:$PWD$>
```
### Executing External Commands
- Any command not recognized as a built-in command will be executed as an external command using `subprocess.run`.
- Example:
```sh
python --version
```
## Output Screenshots

## Test Cases:


## Developer Notes
- The shell uses the `os` module for directory operations and the `subprocess` module to run external commands.
- The `self.prompt_format` variable stores the format of the shell prompt, which can be customized using the `prompt` command.
- The `handle_command` method parses user input and calls the appropriate method to handle the command.
## Future Enhancements
- Add support for more built-in commands.
- Implement command history and autocomplete features.
- Improve error handling and user feedback.
---
Enjoy using the Command Shell! If you encounter any issues or have suggestions for improvements, feel free to contribute or open an issue.