forked from tools/josh
1
0
Fork 0
josh/src/main/js/Main.ts

34 lines
808 B
TypeScript
Raw Normal View History

2019-11-01 11:59:33 +01:00
import {addOnLoad, q} from "./Shared";
import {Terminal} from "./Terminal";
2019-10-27 01:22:23 +02:00
2019-10-31 23:22:37 +01:00
declare global {
interface Window {
/**
* The main terminal.
*/
terminal: Terminal
/**
* Executes a command in the main terminal.
*
* @param command the command to execute
*/
execute: (command: string) => void
}
}
2019-10-27 01:22:23 +02:00
addOnLoad(() => {
window.terminal = new Terminal(
q("#terminal"),
q("#terminalCurrentFocusInput"),
q("#terminalOutput"),
q("#terminalCurrentPrefix")
);
2019-10-31 23:22:37 +01:00
window.execute = (command: string) => window.terminal.processInput(command);
2019-10-27 01:22:23 +02:00
2019-10-31 23:22:37 +01:00
// @ts-ignore: Ugly hack to execute it anyway
if (window.terminal.shell.environment.get("user") !== "")
window.execute("ls");
2019-10-27 01:22:23 +02:00
});