In this post, I’ll walk through how I created the interactive terminal experience that powers this portfolio website.
Why a Terminal?
The idea came from wanting something different from the typical portfolio websites. As a developer who spends most of my day in the terminal, it felt natural to create an interface that feels comfortable and unique.
Tech Stack
The terminal is built with:
- xterm.js - A professional terminal emulator library
- TypeScript - For type safety and better development experience
- Vite - Fast build tool with hot reload
- pnpm workspaces - For managing the monorepo
Core Architecture
Command System
The heart of the terminal is the command system. Each command is a separate module that implements a simple interface:
| |
This makes it easy to add new commands without modifying existing code.
Terminal Controller
The TerminalController class handles:
- User input and key events
- Command parsing and execution
- History navigation
- Tab completion
Here’s a simplified version of how commands are executed:
| |
Theme System
The terminal supports both dark and light Catppuccin themes. Themes are defined as color objects and switched dynamically:
| |
Challenges Faced
1. Terminal Sizing
Making the terminal responsive was tricky. The solution was using the FitAddon from xterm.js and listening to resize events:
| |
2. Command Autocompletion
Implementing tab completion required filtering command names and handling the UI updates:
| |
3. History Navigation
Up/down arrow keys navigate through command history. This requires maintaining a history array and managing the current index:
| |
Adding New Commands
Adding a new command is straightforward. Here’s the links command:
| |
Future Improvements
Some ideas for the future:
- Add file system navigation (
ls,cd,cat) - Implement pipes and command chaining
- Add syntax highlighting for code output
- Create a package manager for commands
- Add animations and sound effects
Conclusion
Building this terminal portfolio was a fun challenge that combined my love for terminal interfaces with modern web development. The modular architecture makes it easy to extend, and TypeScript ensures everything stays maintainable.
If you’re interested in the code, check out the repository linked in the projects section!
Have questions or suggestions? Feel free to reach out!