Compare commits

..

No commits in common. "650afe91a39246c906907c2e25b90ebbcf36e211" and "cf04d4da15faf83e48803fd8b8cf59a3679b782d" have entirely different histories.

6 changed files with 8 additions and 2234 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
node_modules node_modules
yarn.lock
package-lock.json package-lock.json
dist dist

View File

@ -22,5 +22,4 @@ module.exports = (argv, terminal) => {
terminal.write('\033[1;32m' + x + '\033[0m\t'); terminal.write('\033[1;32m' + x + '\033[0m\t');
}); });
terminal.writeln(''); terminal.writeln('');
terminal.writeln('Hint: If you are looking for a guide to use it, run the \x1b[32mguide\33[0m command')
} }

View File

@ -15,7 +15,6 @@ let cmds = {
'echo': require('./echo'), 'echo': require('./echo'),
'exit': require('./exit'), 'exit': require('./exit'),
'systemctl': require('./systemctl'), 'systemctl': require('./systemctl'),
'set-hostname': require('./set-hostname.js'),
'guide': require('./guide'), 'guide': require('./guide'),

View File

@ -1,30 +0,0 @@
const { Terminal } = require("xterm");
const original_data = Object.freeze(data);
global.orig = original_data;
/**
*
* @param {string[]} argv
* @param {Terminal} terminal
*/
module.exports = (argv, terminal, zsh) => {
if (argv.indexOf('--help') !== -1) {
terminal.writeln(`
Usage: ${argv[0]} [hostname] [-R] [--help]
-R Reset it to original IP (${original_data.ip})
--help Show this page`
);
return 0;
}
if (argv.indexOf('-R') !== -1) {
data.ip = original_data.ip;
zsh.update_prompt();
return 0;
}
data.ip = argv[1] || 'resume.js';
zsh.update_prompt();
return 0;
}

View File

@ -2,18 +2,9 @@
import { Terminal } from 'xterm'; import { Terminal } from 'xterm';
import { XTerm } from 'xterm-for-react'; import { XTerm } from 'xterm-for-react';
const memfs = require('memfs');
const fs = require('./fs'); const fs = require('./fs');
global.fs = fs; global.fs = fs;
const cmds = require('./commands'); const cmds = require('./commands');
const sleep = require('../lib/sleep');
// ZSH api to be used in commands (see references)
const zshapi = {
update_prompt,
text_prompt,
pr_char
};
/** /**
* @type { Terminal } * @type { Terminal }
@ -25,14 +16,10 @@ let terminal;
*/ */
let dom; let dom;
let prompt = `\x1b[1;32muser@${data.ip} \x1b[36m~ $ \x1b[0m`; const prompt = `\x1b[1;32muser@${data.ip} \x1b[36m~ $ \x1b[0m`;
let cmd = ''; let cmd = '';
let lastcmd = window.sessionStorage.getItem('last_cmd') || ''; let lastcmd = window.sessionStorage.getItem('last_cmd') || '';
function update_prompt() {
prompt = `\x1b[1;32muser@${data.ip} \x1b[36m~ $ \x1b[0m`;
}
function text_prompt() { function text_prompt() {
return prompt.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''); return prompt.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
} }
@ -57,15 +44,13 @@ function exec_file(f) {
return; return;
} }
// This fails for some reason (vvvv) const executable = fs.accessSync(f, fs.constants.X_OK);
const executable = fs.accessSync(f, memfs.constants.X_OK);
// const executable = true;
if (!executable) { if (!executable) {
terminal.write('zsh: permission denied: ' + f); terminal.writeln('zsh: permission denied: ' + f);
return; return;
} }
terminal.writeln('This is just a simple online resume. It is not big enough to have a script runtime for god\'s sake.'); terminal.writeln('This is an online resume. It is not big enough to have a script runtime.\n');
return; return;
} }
@ -92,7 +77,9 @@ async function exec_cmd() {
if (cmds[command] != undefined) { if (cmds[command] != undefined) {
const startY = terminal.buffer.normal.cursorY const startY = terminal.buffer.normal.cursorY
await cmds[command](c.split(' '), terminal, zshapi); await cmds[command](c.split(' '), terminal);
await (new Promise(resolve => setTimeout(resolve, 10)));
if (terminal.buffer.active.cursorX != 0 && startY != terminal.buffer.active.cursorY) { if (terminal.buffer.active.cursorX != 0 && startY != terminal.buffer.active.cursorY) {
terminal.write('\033[30;47m%\033[0m\n'); terminal.write('\033[30;47m%\033[0m\n');

2182
yarn.lock

File diff suppressed because it is too large Load Diff