summaryrefslogtreecommitdiff
path: root/core/shell.js
blob: b3497d00e148fb7a64e26e0341a04074be1f88b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require('fs');

process.on('SIGINT', () => {

});

try {
    if (!fs.existsSync(process.env.HOME + "/.unish")) fs.mkdirSync(process.env.HOME + "/.unish");
} catch (e) {
    console.log(require('chalk').red("Error: ") + "Unable to create " + process.env.HOME + "/.unish, configuration and history saving are disabled.");
}

try {
    if (!fs.existsSync(process.env.HOME + "/.unish/history.txt")) fs.writeFileSync(process.env.HOME + "/.unish/history.txt", "");
} catch (e) {
    console.log(require('chalk').red("Error: ") + "Unable to create " + process.env.HOME + "/.unish/history.txt, configuration and history saving are disabled.");
}

require('./history');
require('./keyboard');
require('./ui');
require('./prompt');

console.log("Welcome to Unicorn Shell, the modern pony shell.\n© 2023 Equestria.dev Developers\n");

process.env["SHELL"] = process.argv0;

global.directory = process.cwd();
global.env = process.env;

global.delimiters = [" ", ",", ".", "-", "_"];
refreshPS1();
global.cursor = 0;
global.buf = "";

prompt();