Alongside the coreutils WASM commit, record the website repo's commit/date in version.js (SITE_VERSION) and display it next to the existing build info on the playground.
6.4 KiB
+++ title = "Playground" template = "page.html" +++
Try uutils coreutils directly in your browser! This interactive terminal runs Rust coreutils via WebAssembly - no installation needed.
" + 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 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:
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:
?cmd=date- show the current date?cmd=seq 1 10 | factor- factorize numbers 1–10?cmd=echo 'Hello, world!' | sha256sum- hash a string?cmd=sort fruits.txt | uniq -c | sort -rn- count and rank fruit
Multiple commands can be separated by newlines (%0A in the URL):
?cmd=echo hello%0Aecho world- run two commands in sequence
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 examplesclear- clear the terminal screencd- change the current working directorylocale- 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.