PyShell is a powerful, feature-rich shell implemented in pure Python that serves as a modern alternative to traditional shells like bash, fish, and zsh. It combines the power of Python with modern terminal UX principles to create an intuitive and productive command-line experience.
- Syntax Highlighting: Real-time command syntax highlighting with customizable colors
- Intelligent Autocomplete: Smart command and file path completion
- Command History: Persistent history with search functionality
- Modern Interface: Clean, customizable prompt with git branch display
- Built-in Commands: Essential shell commands implemented natively
- Alias System: Create and manage command aliases
- Configuration: Web-based and file-based configuration options
- Rich Terminal Output: Beautiful formatting using the Rich library
- Multiple Themes: Dark and light theme support
- Customizable Prompts: Modern and classic prompt styles
- Git Integration: Automatic git branch detection and display
- Color-Coded Output: Syntax highlighting for commands, paths, and operators
- Web Configuration: Browser-based configuration interface
- Plugin System: Extensible architecture for custom functionality
- Environment Management: Built-in environment variable handling
- Cross-Platform: Works on Linux, macOS, and Windows
- Single File: Entire shell in one executable Python file
# Download the shell
curl -o pyshell.py https://path-to-pyshell/pyshell.py
# Make it executable
chmod +x pyshell.py
# Run the shell
./pyshell.pyPyShell requires Python 3.6+ and optionally the following packages for enhanced features:
# Install optional dependencies for enhanced features
pip install rich textual readline# Basic usage
python pyshell.py
# With custom theme
python pyshell.py --theme dark
# Disable features
python pyshell.py --no-highlighting --no-autocompletecd [directory]- Change directorypwd- Print working directoryls- List directory contents (with rich formatting)
help- Show help informationconfig- Configure shell settingswebconfig- Open web-based configurationalias- Manage command aliases
history- Show recent commandshistory search <pattern>- Search command history
clear- Clear terminalexitorquit- Exit the shell
PyShell supports all standard shell commands:
- File operations:
cp,mv,rm,mkdir,touch - Text processing:
grep,awk,sed,cat,less - System commands:
ps,top,df,du,whoami - Development:
git,python,node,npm,docker
Ctrl+C- Interrupt current commandCtrl+D- Exit the shell (EOF)Up/Down Arrow- Navigate command historyTab- Autocomplete commands and paths
PyShell stores configuration in ~/.pyshell_config.json:
{
"theme": "dark",
"prompt_style": "modern",
"show_git_branch": true,
"syntax_highlighting": true,
"autocomplete_enabled": true,
"aliases": {
"ll": "ls -la",
"..": "cd ..",
"home": "cd ~"
},
"environment_vars": {
"EDITOR": "vim",
"PYTHONPATH": "/usr/local/lib/python3.9"
}
}Access the web-based configuration interface:
pyshell> webconfig
# Open http://localhost:8080 in your browserPyShell supports multiple color themes:
- dark (default) - Dark theme with blue accents
- light - Light theme with soft colors
- modern (default) - Multi-line prompt with git branch
- classic - Traditional single-line prompt
Create custom command aliases:
# Add alias
pyshell> alias add ll "ls -la"
# Remove alias
alias> alias remove ll
# List aliases
pyshell> alias- PyShell - Main shell class coordinating all functionality
- CommandHistory - Manages command history with persistence
- SyntaxHighlighter - Provides real-time syntax highlighting
- AutoCompleter - Intelligent command and path completion
- ShellConfig - Configuration management and persistence
- Rich Library - Beautiful terminal formatting and output
- Textual - Advanced terminal user interfaces (optional)
- Readline - Command line editing and history (Unix systems)
- HTTP Server - Web-based configuration interface
- Single Responsibility - Each component has a clear purpose
- Extensibility - Plugin architecture for custom functionality
- User Experience - Modern, intuitive interface design
- Performance - Efficient command execution and response
- Cross-Platform - Works consistently across operating systems
# Navigate with style
pyshell> cd /home/user/projects
user@hostname:/home/user/projects (main)
❯ ls
# Use aliases for common tasks
user@hostname:/home/user/projects (main)
❯ alias add deploy "git push origin main && ssh server 'cd /app && git pull'"
# Search command history
user@hostname:/home/user/projects (main)
❯ history search git# Git operations with branch display
user@hostname:/home/user/projects (feature-branch)
❯ git status
# Python development
user@hostname:/home/user/projects (feature-branch)
❯ python -m pytest tests/
# Docker operations
user@hostname:/home/user/projects (feature-branch)
❯ docker build -t myapp .| Feature | PyShell | Bash | Fish | Zsh |
|---|---|---|---|---|
| Syntax Highlighting | ✅ Built-in | ❌ Plugin | ✅ Built-in | ✅ Plugin |
| Autocomplete | ✅ Smart | ✅ Basic | ✅ Advanced | ✅ Advanced |
| Configuration | ✅ Web + File | ❌ Manual | ✅ Web | ✅ Manual |
| Git Integration | ✅ Built-in | ❌ Manual | ✅ Plugin | ✅ Plugin |
| Python Integration | ✅ Native | ❌ Limited | ❌ Limited | ❌ Limited |
| Single File | ✅ Yes | ❌ No | ❌ No | ❌ No |
-
Colors not showing
- Ensure terminal supports 256 colors
- Try
--theme lightoption - Check
$TERMenvironment variable
-
Autocomplete not working
- Install
readlinemodule:pip install readline - Enable autocomplete in config:
config autocomplete true
- Install
-
Performance issues
- Disable syntax highlighting:
--no-highlighting - Reduce history size in config file
- Check system resources
- Disable syntax highlighting:
-
Web config not loading
- Ensure port 8080 is available
- Check firewall settings
- Try different browser
# Show built-in help
pyshell> help
# Check version
pyshell> python pyshell.py --version
# Verbose mode for debugging
pyshell> python -v pyshell.pyPyShell's architecture makes it easy to add new features:
# Add custom command
class PyShell:
def handle_builtin_command(self, command: str) -> bool:
if command == "mycommand":
print("My custom command!")
return True
return super().handle_builtin_command(command)Create plugins by extending the base functionality:
class PyShellPlugin:
def __init__(self, shell):
self.shell = shell
def register_commands(self):
self.shell.register_command("myplugin", self.my_command)
def my_command(self, args):
print("Plugin command executed!")PyShell is released under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit pull requests or report issues.
- Inspired by modern shells like Fish and Zsh
- Built with the excellent Rich library for beautiful terminal output
- Thanks to the Python community for the powerful ecosystem