'use client' import { motion } from 'framer-motion' import { useEffect, useRef, useState } from 'react' const commands: Record = { help: `Available commands: ls - List services kubectl - Cluster info terraform - Infrastructure argocd - Deployments kafka - Message broker about - About me clear - Clear terminal`, ls: `storage/ monitoring/ cicd/ sqs/ temporal/ iam/`, kubectl: `Nodes: 3 (talos-cp-1, talos-worker-1, talos-worker-2) Pods: 42 running Uptime: 99.2% Cluster Version: v1.36.1`, terraform: `Modules: 18 deployed Services: Kafka, PostgreSQL, MinIO, Grafana Storage: Longhorn (3-replica) Network: Cilium eBPF CNI`, argocd: `Applications: 12 Synced: 11/12 Last Sync: 2 min ago Health: Healthy`, kafka: `Brokers: 3 (KRaft) Replication Factor: 3 Min ISR: 2 Topics: 5 active Throughput: ~1K msgs/sec`, about: `Rock Liang - Senior Full-Stack Systems Engineer Experience: 5+ years (AWS, RBC, Homelab) Focus: Infrastructure × Backend × LLM Systems Tech: Go, Java, Python, C++ | Kubernetes, Terraform, gRPC Current: Building production homelab + LLM inference optimization Open Source: go-flink (distributed DataLakeHouse)`, } export function InteractiveTerminal() { const [input, setInput] = useState('') const [history, setHistory] = useState<{ cmd: string; output: string }[]>([]) const [isOpen, setIsOpen] = useState(false) const terminalRef = useRef(null) useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if ((e.metaKey || e.ctrlKey) && e.key === 'k') { e.preventDefault() setIsOpen(!isOpen) } } window.addEventListener('keydown', handleKeyDown) return () => window.removeEventListener('keydown', handleKeyDown) }, [isOpen]) const handleCommand = (cmd: string) => { const trimmed = cmd.trim().toLowerCase() if (trimmed === 'clear') { setHistory([]) setInput('') return } const output = commands[trimmed] || `command not found: ${cmd}` setHistory([...history, { cmd, output }]) setInput('') setTimeout(() => { terminalRef.current?.scrollTo(0, terminalRef.current.scrollHeight) }, 0) } return ( {!isOpen ? ( ) : (
ZSH_THEME="robbyrussell"
{history.length === 0 && (
type 'help' for commands
)} {history.map((entry, i) => (
% {entry.cmd}
{entry.output}
))}
% setInput(e.target.value)} onKeyPress={(e) => { if (e.key === 'Enter') handleCommand(input) }} placeholder="" className="flex-1 bg-transparent text-green-400 font-mono text-sm outline-none ml-1" autoFocus />
)}
) }