Files

7.0 KiB
Raw Permalink Blame History

+++ title = "Playground" template = "page.html" +++

Try uutils coreutils directly in your browser! This interactive terminal runs Rust coreutils via WebAssembly - no installation needed.

English (en-US) Missing a translation or your language? Help translate on Weblate

<script src="/wasm/locales.js" defer></script> <script src="/wasm/version.js" defer></script> <script src="/wasm/commands.js" defer></script> <script src="/js/wasm-terminal.js" defer></script> <script defer> document.addEventListener("DOMContentLoaded", function() { initPlayground("wasm-playground"); // Populate the locale dropdown from the build-generated list if (typeof WASM_LOCALES !== "undefined") { var sel = document.getElementById("locale-select"); WASM_LOCALES.forEach(function(loc) { if (loc === "en-US") return; // already the default option var opt = document.createElement("option"); opt.value = loc; opt.textContent = loc; sel.appendChild(opt); }); } // Populate the "Available commands" list from the build-generated list if (typeof WASM_COMMANDS !== "undefined" && Array.isArray(WASM_COMMANDS)) { var listEl = document.getElementById("wasm-commands-list"); if (listEl) { listEl.innerHTML = WASM_COMMANDS.slice().sort().map(function(c) { return "" + c + ""; }).join(" "); } } // Show the uutils commit that was used to build the WASM binary, // and the uutils.github.io commit the site itself was built from. var el = document.getElementById("playground-version"); if (el) { var parts = []; if (typeof UUTILS_WASM_VERSION !== "undefined") { var date = UUTILS_WASM_VERSION.date.split("T")[0]; var url = "https://github.com/uutils/coreutils/commit/" + UUTILS_WASM_VERSION.commit; parts.push('Built from uutils/coreutils ' + UUTILS_WASM_VERSION.short + ' (' + date + ')'); } if (typeof UUTILS_GREP_VERSION !== "undefined") { var grepDate = UUTILS_GREP_VERSION.date.split("T")[0]; var grepUrl = "https://github.com/uutils/grep/commit/" + UUTILS_GREP_VERSION.commit; parts.push('grep ' + UUTILS_GREP_VERSION.short + ' (' + grepDate + ')'); } if (typeof SITE_VERSION !== "undefined") { var siteDate = SITE_VERSION.date.split("T")[0]; var siteUrl = "https://github.com/uutils/uutils.github.io/commit/" + SITE_VERSION.commit; parts.push('site ' + SITE_VERSION.short + ' (' + siteDate + ')'); } el.innerHTML = parts.join(' · '); } }); </script>

Try it out

Click an example to run it in the terminal:

seq 1 20 | factor sort fruits.txt | uniq -c | sort -rn cut -d, -f2 csv.txt | tail -4 | sort -n echo 'rust coreutils in the browser' | tr a-z A-Z echo 'こんにちは世界' | base64 | base64 -d echo 'Hello, world!' | sha256sum shuf -n3 names.txt | nl seq 100 | shuf -n5 | sort -n paste -d: names.txt numbers.txt | head -5 echo 'مرحبا بالعالم' | wc -c -w printf '🐑\n🐑\n🐑\n🐑\n🐑\n' | nl echo '🍎,🍌,🍒,🥝' | cut -d🍌 -f2 printf '🍒 cherry\n🍎 apple\n🍌 banana\n' | sort -k2 printf '🍎 apple\n🍌 banana\n🍒 cherry\n🥝 kiwi\n' | grep 🍌 sort -n < numbers.txt | head -3 date uname -a
<script> document.querySelectorAll('.playground-example').forEach(function(btn) { btn.addEventListener('click', function() { var cmd = btn.textContent; // Reflect the clicked example in the URL so it can be shared/bookmarked. var url = new URL(window.location.href); url.searchParams.set('cmd', cmd); window.history.replaceState(null, '', url); document.getElementById('wasm-playground').scrollIntoView({ behavior: 'smooth' }); if (window.runInTerminal) { window.runInTerminal(cmd); } }); }); </script>

Sharing commands via URL

You can pre-fill the terminal with a command using the ?cmd= URL parameter. The command runs automatically when the page loads - great for sharing examples or linking from documentation.

Examples:

Multiple commands can be separated by newlines (%0A in the URL):

Available commands

The following commands run as real Rust coreutils compiled to WebAssembly:

Loading the list of available commands…

The following are shell builtins implemented in JavaScript:

  • help - list available commands and examples
  • clear - clear the terminal screen
  • cd - change the current working directory
  • locale - show or change the current locale

Some commands (e.g. chcon, runcon, etc.) are not yet available in the WASM build because they depend on platform-specific syscalls not fully supported by WebAssembly/WASI.

We are actively working on adding more commands as we improve WASI compatibility in uutils coreutils.

Curious about how this all works under the hood? Read the technical deep-dive on the playground architecture.

The source code for this website (including the playground) is available on GitHub.