Skip to content

Commit 493e563

Browse files
committed
Demonstrate how to use run() in example
1 parent 781ebf3 commit 493e563

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

examples/simple/script.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import LinuxBrowserShell from "linux-browser-shell"
1+
import {LinuxBrowserShell} from "linux-browser-shell"
22

33
const shell = new LinuxBrowserShell(
44
{
@@ -21,6 +21,15 @@ shell.boot().then(() => {
2121
console.log("Booted")
2222
})
2323

24+
// Save state of the VM. You can then later load it using the `initial_state` setting.
2425
document.getElementById("save").onclick = async function () {
2526
shell.downloadState()
2627
}
28+
29+
// Demonstrate how to send commands to a Terminal.
30+
// You can use this in the developer console, using `run("uname -a")` for example.
31+
window.run = (cmd) => {
32+
tty0.run(cmd).then((res) => {
33+
console.log(res)
34+
})
35+
}
-27.7 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"scripts": {
2626
"prepare": "vite build",
27-
"test": "vitest --browser=chrome"
27+
"test": "vitest"
2828
},
2929
"dependencies": {
3030
"async-mutex": "^0.4.0",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Mutex} from "async-mutex"
55
import {Terminal as XTerm} from "xterm"
66

77
export class Terminal {
8-
private prompt = "/ # "
8+
private prompt = "# "
99
private mutex = new Mutex()
1010
private mutex2 = new Mutex()
1111

0 commit comments

Comments
 (0)