app/components/Terminal.tsx) provides an interactive command-line interface for navigating Javier’s portfolio. It supports file system navigation, document reading, and special commands.
Architecture Overview
Line Types
Terminal output is composed of typed line objects:State Management
Boot Sequence
clear command.
Command Execution Flow
Push Helper Function
File System Structure
Virtual Path Hierarchy
Path Validation
Available Commands
Navigation Commands
ls / dir - List directory contents
ls / dir - List directory contents
- Lists folders when in home directory
- Lists files when in a category directory
- Shows full details when inside a file “directory”
cd - Change directory
cd - Change directory
cdorcd ~returns to homecd ..goes up one levelcd <folder>enters a folder (with validation)- Shows error for invalid paths
File Reading Commands
cat - Read file contents
cat - Read file contents
- Accepts filename with or without
.txtextension - Context-aware: only searches files in current directory
- Shows project/work/study details based on location
- Displays clickable URLs for projects
open - Open/download files
open - Open/download files
Information Commands
help - Show available commands
help - Show available commands
whoami - Display user identity
whoami - Display user identity
about - Extended bio
about - Extended bio
textos.ts:Special Commands
ping - Quick project lookup
ping - Quick project lookup
cd proyectos)git init - GitHub profile
git init - GitHub profile
clear - Clear terminal output
clear - Clear terminal output
bot_javier - AI chatbot
bot_javier - AI chatbot
Tab Completion System
Completion Logic
Tab Behavior
- Single match: Auto-completes and adds space
- Multiple matches: Shows all options (like bash)
- Context-aware: Only suggests valid options for current path
Example Usage
- Command Completion
- Argument Completion
- Multiple Matches
Command History
Arrow Key Navigation
↑: Navigate back through history (older commands)↓: Navigate forward through history (newer commands)- At end of history: Clears input
- History persists during session (lost on page refresh)
History Storage
- New commands prepended to array
- Index -1 = current input (not in history)
- No persistence between sessions
Line Rendering
Adding New Commands
Step 1: Define Command Function
Step 2: Add to Switch Statement
Step 3: Add to Tab Completion
Step 4: Add to Help Command
Best Practices
Command Design
- Use lowercase command names
- Provide clear usage messages for missing arguments
- Always add blank lines before/after output for readability
- Use semantic colors (green for success, red for errors, cyan for info)
Error Handling
Output Formatting
- Use
SEPconstant for visual separators - Indent content with
" "(2 spaces) - Use consistent color scheme across commands
- Add blank lines for visual grouping
See Also
- Desktop System - Terminal window integration
- Components: Terminal - Full component API
- Data: textos.ts - Content source