diff --git a/src/Terminal/Terminal.ts b/src/Terminal/Terminal.ts
index ba2e3a996..cc94f48ad 100644
--- a/src/Terminal/Terminal.ts
+++ b/src/Terminal/Terminal.ts
@@ -656,6 +656,9 @@ export class Terminal {
case iTutorialSteps.TerminalLs:
if (commandArray.length === 1 && commandArray[0] == "ls") {
iTutorialNextStep();
+ } else if (commandArray[0] == "1s") {
+ this.error("Command '1s' not found. Did you mean 'ls' with a lowercase L?");
+ return;
} else {
this.error(errorMessageForBadCommand);
return;
@@ -800,7 +803,11 @@ export class Terminal {
commandArray.shift();
const f = TerminalCommands[commandName.toLowerCase()];
- if (!f) return this.error(`Command ${commandName} not found`);
+ if (!f) {
+ const similarCommands = findSimilarCommands(commandName);
+ const didYouMeanString = similarCommands.length ? ` Did you mean: ${similarCommands.join(" or ")}?` : "";
+ return this.error(`Command ${commandName} not found.${didYouMeanString}`);
+ }
f(commandArray, currentServer);
}
@@ -813,3 +820,17 @@ export class Terminal {
});
}
}
+
+function findSimilarCommands(command: string): string[] {
+ const commands = Object.keys(TerminalCommands);
+ const offByOneLetter = commands.filter((c) => {
+ if (c.length !== command.length) return false;
+ let diff = 0;
+ for (let i = 0; i < c.length; i++) {
+ if (c[i] !== command[i]) diff++;
+ }
+ return diff === 1;
+ });
+ const subset = commands.filter((c) => c.includes(command)).sort((a, b) => a.length - b.length);
+ return Array.from(new Set([...offByOneLetter, ...subset])).slice(0, 3);
+}
diff --git a/src/ui/InteractiveTutorial/InteractiveTutorialRoot.tsx b/src/ui/InteractiveTutorial/InteractiveTutorialRoot.tsx
index ef08c8ac7..175ecc021 100644
--- a/src/ui/InteractiveTutorial/InteractiveTutorialRoot.tsx
+++ b/src/ui/InteractiveTutorial/InteractiveTutorialRoot.tsx
@@ -146,6 +146,9 @@ export function InteractiveTutorialRoot(): React.ReactElement {
{"[home /]> ls"}
+
+
( "ls" is short for "list" )
+
>
),
canNext: false,
@@ -156,7 +159,7 @@ export function InteractiveTutorialRoot(): React.ReactElement {
{"[home /]> ls"}
{" "}
- is a basic command that shows files on the computer. Right now, it shows that you have a program called{" "}
+ is a basic command that lists the files on the computer. Right now, it shows that you have a program called{" "}
NUKE.exe on your computer. We'll get to what this does later.
Using your home computer's terminal, you can connect to other machines throughout the world. Let's do that