mirror of
https://github.com/Kyren223/website.git
synced 2025-12-28 08:54:37 +00:00
Added the terminal and a bunch of commands, still missing vim command
and also incomplete rm -rf
This commit is contained in:
BIN
public/fonts/Monocraft-Black-Italic.ttf
Normal file
BIN
public/fonts/Monocraft-Black-Italic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-Black.ttf
Normal file
BIN
public/fonts/Monocraft-Black.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-Bold-Italic.ttf
Normal file
BIN
public/fonts/Monocraft-Bold-Italic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-Bold.ttf
Normal file
BIN
public/fonts/Monocraft-Bold.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-ExtraLight-Italic.ttf
Normal file
BIN
public/fonts/Monocraft-ExtraLight-Italic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-ExtraLight.ttf
Normal file
BIN
public/fonts/Monocraft-ExtraLight.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-Italic.ttf
Normal file
BIN
public/fonts/Monocraft-Italic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-Light-Italic.ttf
Normal file
BIN
public/fonts/Monocraft-Light-Italic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-Light.ttf
Normal file
BIN
public/fonts/Monocraft-Light.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-SemiBold-Italic.ttf
Normal file
BIN
public/fonts/Monocraft-SemiBold-Italic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft-SemiBold.ttf
Normal file
BIN
public/fonts/Monocraft-SemiBold.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Monocraft.ttf
Normal file
BIN
public/fonts/Monocraft.ttf
Normal file
Binary file not shown.
@@ -102,8 +102,31 @@ import TerminalBorder from "@components/TerminalBorder.astro";
|
||||
}
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
var maxLines = 15;
|
||||
var terminal: string[] = ["Coming soon!"];
|
||||
var terminal: string[] = [];
|
||||
const rootDirs = [
|
||||
"bin",
|
||||
"boot",
|
||||
"dev",
|
||||
"etc",
|
||||
"home",
|
||||
"lib",
|
||||
"lib64",
|
||||
"lost+found",
|
||||
"nix",
|
||||
"proc",
|
||||
"root",
|
||||
"run",
|
||||
"srv",
|
||||
"sys",
|
||||
"tmp",
|
||||
"usr",
|
||||
"var",
|
||||
];
|
||||
|
||||
function write(line: string) {
|
||||
const maxChars = 98;
|
||||
@@ -129,29 +152,276 @@ import TerminalBorder from "@components/TerminalBorder.astro";
|
||||
output.innerHTML = text;
|
||||
}
|
||||
|
||||
function runCommand(cmd: string) {
|
||||
write(`$ ${cmd}`);
|
||||
console.log(`$ ${cmd}`);
|
||||
console.log(terminal);
|
||||
switch (cmd) {
|
||||
case "":
|
||||
break;
|
||||
case "clear":
|
||||
terminal = [];
|
||||
break;
|
||||
case "test":
|
||||
write('testing "trying to get more info"...');
|
||||
write('test "trying to get more info" failed');
|
||||
write("executed 1 test, 0 succeeded, 1 failed");
|
||||
break;
|
||||
case "thing":
|
||||
break;
|
||||
case "thing":
|
||||
break;
|
||||
default:
|
||||
write(`${cmd}: command not found`);
|
||||
break;
|
||||
var isSudo = false;
|
||||
var rootPassword = "123";
|
||||
var leftPasswordTries = 0;
|
||||
var sudoCommand = "";
|
||||
const knownCommands = [
|
||||
"clear",
|
||||
"test",
|
||||
"whoami",
|
||||
"pwd",
|
||||
"sudo",
|
||||
"rm",
|
||||
"emacs",
|
||||
"set",
|
||||
];
|
||||
|
||||
async function runCommand(input: string) {
|
||||
if (leftPasswordTries != 0) {
|
||||
if (input == rootPassword) {
|
||||
// await sleep(1000);
|
||||
leftPasswordTries = 0
|
||||
isSudo = true;
|
||||
runCommand(sudoCommand);
|
||||
isSudo = false;
|
||||
sudoCommand = "";
|
||||
} else if (leftPasswordTries == 1) {
|
||||
// await sleep(1000);
|
||||
write("sudo: 3 incorrect password attempts");
|
||||
leftPasswordTries -= 1;
|
||||
sudoCommand = "";
|
||||
} else {
|
||||
// await sleep(1000);
|
||||
write("Sorry, try again.");
|
||||
write("[sudo] password for root:");
|
||||
leftPasswordTries -= 1;
|
||||
}
|
||||
updateTerminal();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isSudo) {
|
||||
write(`$ ${input}`);
|
||||
console.log(`$ ${input}`);
|
||||
}
|
||||
|
||||
var args = input.split(" ").slice(1);
|
||||
var cmd = input.split(" ")[0];
|
||||
|
||||
if (cmd == "") return;
|
||||
|
||||
if (args.length == 0) {
|
||||
switch (cmd) {
|
||||
case "clear":
|
||||
terminal = [];
|
||||
break;
|
||||
|
||||
case "test":
|
||||
if (isSudo) {
|
||||
write('running "trying to get more info"...');
|
||||
updateTerminal();
|
||||
await sleep(1000);
|
||||
write("fetching notes...");
|
||||
updateTerminal();
|
||||
await sleep(2000);
|
||||
write(
|
||||
"I love the look with 'set theme catppuccin', especially with the minecraft font!",
|
||||
);
|
||||
write("Been using it for a while in emacs");
|
||||
updateTerminal();
|
||||
await sleep(100);
|
||||
write('test "trying to get more info" succeeded');
|
||||
updateTerminal();
|
||||
await sleep(100);
|
||||
write("executed 1 test, 1 succeeded, 0 failed");
|
||||
} else {
|
||||
write('running "trying to get more info"...');
|
||||
updateTerminal();
|
||||
await sleep(1000);
|
||||
write('test "trying to get more info" failed');
|
||||
updateTerminal();
|
||||
await sleep(100);
|
||||
write("executed 1 test, 0 succeeded, 1 failed");
|
||||
}
|
||||
break;
|
||||
|
||||
case "whoami":
|
||||
write("sandbox");
|
||||
break;
|
||||
case "pwd":
|
||||
write("/home/sandbox");
|
||||
break;
|
||||
|
||||
case "sudo":
|
||||
write(`Usage: sudo [COMMAND]`);
|
||||
break;
|
||||
|
||||
case "emacs":
|
||||
write(`emacs: command not found`);
|
||||
write(`The command 'emacs' is not available, but there is a similar command:`);
|
||||
write(`- vim`);
|
||||
write(`- nvim`);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (knownCommands.includes(cmd)) {
|
||||
write(`${cmd}: missing operand`);
|
||||
write(`Try '${cmd} --help' for more information.`);
|
||||
} else {
|
||||
write(`${cmd}: command not found`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (cmd == "rm") {
|
||||
if (args.length == 2 && (args[0] == "-rf" || args[0] == "-fr")) {
|
||||
if (args[1] == "/") {
|
||||
write("rm: it is dangerous to operate recursively on '/'");
|
||||
write(
|
||||
"rm: use --no-preserve-root to override this failsafe",
|
||||
);
|
||||
} else if (args[1] == "." || args[1] == "..") {
|
||||
write(
|
||||
`rm: refusing to remove '.' or '..' directory: skipping '${args[1]}'`,
|
||||
);
|
||||
} else {
|
||||
if (!args[1].startsWith("/")) {
|
||||
args[1] = "/" + args[1];
|
||||
}
|
||||
write(`rm: cannot remove '${args[1]}': Permission denied`);
|
||||
}
|
||||
} else if (
|
||||
args.length == 3 &&
|
||||
(args[0] == "-rf" || args[0] == "-fr") &&
|
||||
args[2] == "--no-preserve-root"
|
||||
) {
|
||||
for (const dir of rootDirs) {
|
||||
await sleep(30);
|
||||
write(`rm: cannot remove '/${dir}': Permission denied`);
|
||||
updateTerminal();
|
||||
}
|
||||
} else if (args.length == 1 && args[0] == "--help") {
|
||||
write(`Usage: rm [OPTION]... [FILE]...`);
|
||||
write(`Remove (unlink) the FILE(s).`);
|
||||
} else {
|
||||
write(`${cmd}: unrecognized options '${args.join(" ")}'`);
|
||||
write(`Try '${cmd} --help' for more information.`);
|
||||
}
|
||||
} else if (cmd == "sudo") {
|
||||
if (isSudo) {
|
||||
if (knownCommands.includes(args[0])) {
|
||||
runCommand(args.join(" "));
|
||||
} else {
|
||||
write(`${cmd}: ${args[0]}: command not found`);
|
||||
}
|
||||
isSudo = false;
|
||||
} else {
|
||||
sudoCommand = input;
|
||||
leftPasswordTries = 3;
|
||||
write("[sudo] password for root:");
|
||||
}
|
||||
} else if (cmd == "set" && args.length == 2 && args[0] == "font") {
|
||||
var unknown = false;
|
||||
switch (args[1]) {
|
||||
case "default":
|
||||
window.setTheme({
|
||||
font: "Jetbrains Mono",
|
||||
});
|
||||
break;
|
||||
|
||||
case "minecraft":
|
||||
window.setTheme({
|
||||
font: "Monocraft",
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
unknown = true;
|
||||
break;
|
||||
}
|
||||
if (unknown) {
|
||||
write(`${cmd}: unknown ${args[0]} '${args[1]}'`);
|
||||
} else {
|
||||
write(`${cmd}: ${args[0]} set to '${args[1]}'`);
|
||||
}
|
||||
} else if (cmd == "set" && args.length == 2 && args[0] == "theme") {
|
||||
var unknown = false;
|
||||
switch (args[1]) {
|
||||
case "default":
|
||||
window.setTheme({
|
||||
primary: "#54d7a9",
|
||||
secondary: "#9b7eca",
|
||||
accent: "#7ed4fb",
|
||||
extra: "#8fcc75",
|
||||
text: "#ffffff",
|
||||
alt: "#999999",
|
||||
background: "#000000",
|
||||
});
|
||||
break;
|
||||
|
||||
case "catppuccin":
|
||||
window.setTheme({
|
||||
primary: "#94e2d5",
|
||||
secondary: "#b4befe",
|
||||
accent: "#74c7ec",
|
||||
extra: "#a6e3a1",
|
||||
text: "#cdd6f4",
|
||||
alt: "#585b70",
|
||||
background: "#1e1e2e",
|
||||
});
|
||||
break;
|
||||
|
||||
case "invisible":
|
||||
case "hide":
|
||||
case "black":
|
||||
case "dark":
|
||||
window.setTheme({
|
||||
primary: "#000000",
|
||||
secondary: "#000000",
|
||||
accent: "#000000",
|
||||
extra: "#000000",
|
||||
text: "#000000",
|
||||
alt: "#000000",
|
||||
background: "#000000",
|
||||
});
|
||||
break;
|
||||
|
||||
case "blind":
|
||||
case "sun":
|
||||
case "light":
|
||||
case "white":
|
||||
case "flashbang":
|
||||
case "flashlight":
|
||||
window.setTheme({
|
||||
primary: "#009399",
|
||||
secondary: "#440b8e",
|
||||
accent: "#177282",
|
||||
extra: "#40a02b",
|
||||
text: "#000000",
|
||||
alt: "#4d4d4d",
|
||||
background: "#ffffff",
|
||||
});
|
||||
break;
|
||||
|
||||
case "banana":
|
||||
window.setTheme({
|
||||
primary: "#ffdd44",
|
||||
secondary: "#9b7eca",
|
||||
accent: "#7ed4fb",
|
||||
extra: "#000000",
|
||||
text: "#ffffff",
|
||||
alt: "#999999",
|
||||
background: "#000000",
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
unknown = true;
|
||||
break;
|
||||
}
|
||||
if (unknown) {
|
||||
write(`${cmd}: unknown ${args[0]} '${args[1]}'`);
|
||||
} else {
|
||||
write(`${cmd}: ${args[0]} set to '${args[1]}'`);
|
||||
}
|
||||
} else {
|
||||
if (knownCommands.includes(cmd)) {
|
||||
write(`${cmd}: unrecognized options '${args.join(" ")}'`);
|
||||
} else {
|
||||
write(`${cmd}: command not found`);
|
||||
}
|
||||
}
|
||||
|
||||
updateTerminal();
|
||||
}
|
||||
|
||||
|
||||
108
src/styles/fonts/Monocraft.css
Normal file
108
src/styles/fonts/Monocraft.css
Normal file
@@ -0,0 +1,108 @@
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-ExtraLight.ttf") format("truetype");
|
||||
font-weight: 100;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-ExtraLight-Italic.ttf") format("truetype");
|
||||
font-weight: 100;
|
||||
font-style: italic;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-ExtraLight.ttf") format("truetype");
|
||||
font-weight: 200;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-ExtraLight-Italic.ttf") format("truetype");
|
||||
font-weight: 200;
|
||||
font-style: italic;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Light.ttf") format("truetype");
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Light-Italic.ttf") format("truetype");
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft.ttf") format("truetype");
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Italic.ttf") format("truetype");
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft.ttf") format("truetype");
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Italic.ttf") format("truetype");
|
||||
font-weight: 500;
|
||||
font-style: italic;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-SemiBold.ttf") format("truetype");
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-SemiBold-Italic.ttf") format("truetype");
|
||||
font-weight: 600;
|
||||
font-style: italic;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Bold.ttf") format("truetype");
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Bold-Italic.ttf") format("truetype");
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Black.ttf") format("truetype");
|
||||
font-weight: 800;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Black-Italic.ttf") format("truetype");
|
||||
font-weight: 800;
|
||||
font-style: italic;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Black.ttf") format("truetype");
|
||||
font-weight: 900;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Monocraft";
|
||||
src: url("/fonts/Monocraft-Black-Italic.ttf") format("truetype");
|
||||
font-weight: 900;
|
||||
font-style: italic;
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
@import url("@styles/fonts/JetBrainsMono.css");
|
||||
|
||||
@font-face {
|
||||
font-family: 'Monocraft';
|
||||
src: url('/fonts/Monocraft.ttf') format('truetype');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
:root {
|
||||
--primary: #54d7a9;
|
||||
--secondary: #9b7eca;
|
||||
@@ -8,6 +16,7 @@
|
||||
--text: #ffffff;
|
||||
--alt: #999999;
|
||||
--background: #000000;
|
||||
--font: "Jetbrains Mono", monospace;
|
||||
}
|
||||
|
||||
* {
|
||||
@@ -18,7 +27,7 @@
|
||||
html {
|
||||
background-color: var(--background);
|
||||
color: var(--text);
|
||||
font-family: "Jetbrains Mono", monospace;
|
||||
font-family: var(--font);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user