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.
- Change directory (
cd
) - List directory contents (
ls
) - Execute external commands
- Exit the shell (
exit
) - Customize the shell prompt (
prompt
)
- Python 3.x
- Ensure you have Python 3.x installed on your system.
- Download or clone the shell script to your local machine.
- Open your terminal or command prompt.
- Navigate to the directory where the script is located.
- Run the script using Python:
python shell.py
- Change the current working directory.
- Example:
cd /path/to/directory
- List the contents of the specified directory. If no directory is specified, it lists the contents of the current directory.
- Example:
ls /path/to/directory
- Exit the shell.
- Customize the shell prompt format.
- Placeholders:
$PWD$
: Current working directory$HOME$
: Home directory
- Example:
prompt MyShell:$PWD$>
- Any command not recognized as a built-in command will be executed as an external command using
subprocess.run
. - Example:
python --version
- The shell uses the
os
module for directory operations and thesubprocess
module to run external commands. - The
self.prompt_format
variable stores the format of the shell prompt, which can be customized using theprompt
command. - The
handle_command
method parses user input and calls the appropriate method to handle the command.
- 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.