Project 21: Virtual Terminal
40 min read
Command ParsingVirtual File SystemTab CompletionTerminal EmulationState ManagementTheming
📋 Project Brief
Build a web-based terminal emulator that looks and behaves like a real command line interface. Implement a virtual file system, command history navigation, tab completion, and custom theming. This project demonstrates advanced string parsing and state management.
✅ Feature Requirements
Feature 1: Command History
Acceptance Criteria:
- Pressing ↑ cycles through previous commands (most recent first)
- Pressing ↓ cycles forward through history
- History persists in localStorage (max 100 entries)
- A
historycommand lists all previous commands history clearwipes the history
Feature 2: Virtual File System
Acceptance Criteria:
ls— lists files and folders in the current directorycd <dir>— changes directory;cd ..goes up one levelmkdir <name>— creates a new directorytouch <name>— creates a new filecat <file>— displays file contentsrm <name>— removes a file or empty directorypwd— prints the current working directory- The file system is represented as a nested JavaScript object and persists in localStorage
Feature 3: Terminal Theming
Acceptance Criteria:
- Preset themes: "Classic Green" (green on black), "Matrix" (green rain animation), "Ubuntu" (purple/orange), "Dracula"
- A
theme <name>command switches themes - Custom prompt format:
user@terminal:~/path $ - Font must be monospace; support for font size adjustment
Feature 4: Tab Completion
Acceptance Criteria:
- Pressing Tab auto-completes command names and file/directory names
- If multiple matches exist, show all options (like bash)
- Double-Tab lists all available commands
Feature 5: Special Commands
Acceptance Criteria:
help— lists all available commands with descriptionsclear— clears the terminal outputecho <text>— prints text to the terminaldate— shows current date and timewhoami— displays the "username"sudo <anything>— triggers a fun "Access Denied" animation
📊 Command Parser Requirements
| Input | Parsed As |
|---|---|
ls | { command: "ls", args: [] } |
cd documents | { command: "cd", args: ["documents"] } |
echo "hello world" | { command: "echo", args: ["hello world"] } |
mkdir "my folder" | { command: "mkdir", args: ["my folder"] } |
🧪 Testing Checklist
- Unit test command parser (handling quotes, spaces, special characters)
- Unit test file system operations (create, delete, navigate)
- Unit test tab completion algorithm
- Integration test: create a folder, navigate into it, create a file, cat it
- A11y: terminal output must be accessible to screen readers via
aria-live
🚀 Stretch Goals
- Add pipe support:
ls | grep .txt - Implement
nano <file>— a simple in-terminal text editor - Add command aliases
- Implement a "boot sequence" animation on first load