gpt-4.1-mini-2025-04-14· OpenAI LMArena Human Preference 140K
Create a single html Termux clone
- User
Create a single html Termux clone
- Assistant
Creating a single HTML file that mimics a very basic Termux-like terminal emulator is possible using HTML, CSS, and JavaScript. This won't be a full Linux environment but a simple interactive terminal interface that accepts commands and shows output.
Here’s a minimal example of a Termux-style terminal emulator in a single HTML file:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Termux Clone</title> <style> body { margin: 0; background: #000; color: #0f0; font-family: monospace; font-size: 16px; display: flex; height: 100vh; align-items: center; justify-content: center; } #terminal { background: #000; border: 2px solid #0f0; padding: 10px; width: 90vw; max-width: 800px; height: 80vh; overflow-y: auto; box-sizing: border-box; display: flex; flex-direction: column; } #output { flex-grow: 1; white-space: pre-wrap; } #input-line { display: flex; } #prompt { user-select: none; } #cmdline { background: transparent; border: none; color: #0f0; outline: none; flex-grow: 1; font-family: monospace; font-size: 16px; } </style> </head> <body> <div id="terminal" tabindex="0"> <div id="output"></div> <div id="input-line"> <span id="prompt">termux$ </span> <input type="text" id="cmdline" autofocus autocomplete="off" spellcheck="false" /> </div> </div> <script> const output = document.getElementById('output'); const cmdline = document.getElementById('cmdline'); const prompt = 'termux$ '; // Simple command handlers const commands = { help: () => `Available commands: help - Show this help message date - Show current date and time echo [txt] - Echo text clear - Clear the terminal whoami - Show user name uname - Show system info exit - Close the terminal (reload page) `, date: () => new Date().toString(), echo: (args) => args.join(' '), clear: () => { output.textContent = ''; return ''; }, whoami: () => 'user', uname: () => 'Termux-Clone JS v1.0', exit: () => { location.reload(); return ''; } }; function printOutput(text) { output.textContent += text + '\n'; output.parentElement.scrollTop = output.parentElement.scrollHeight; } cmdline.addEventListener('keydown', e => { if (e.key === 'Enter') { const input = cmdline.value.trim(); printOutput(prompt + input); if (input) { const [cmd, ...args] = input.split(' '); if (commands[cmd]) { const result = commands[cmd](args); if (result !== undefined && result !== '') { printOutput(result); } } else { printOutput(`command not found: ${cmd}`); } } cmdline.value = ''; } }); // Focus input on terminal click document.getElementById('terminal').addEventListener('click', () => { cmdline.focus(); }); </script> </body> </html>
How it works:
- The page shows a black terminal window with green text.
- You get a prompt
termux$and an input box. - You can type commands like
help,date,echo hello,clear,whoami,uname, andexit. - The output appears above the input line.
- The
exitcommand reloads the page (simulating closing the terminal). - The terminal scrolls automatically as output grows.
To use:
- Save the above code as
termux.html. - Open it in any modern browser.
- Type commands and press Enter.
Limitations:
- This is a frontend-only simulation — no real shell or Linux commands.
- No file system or real process execution.
- Just a fun interactive terminal UI clone.
If you want a more advanced terminal emulator with real shell access, you’d need backend support or a WebAssembly Linux environment (like JSLinux).
If you want me to add more commands or features, just ask!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.