Compare commits
2 Commits
a598fa9364
...
0d55e924be
Author | SHA1 | Date |
---|---|---|
b1ek | 0d55e924be | |
b1ek | d76b8db1a0 |
|
@ -7,7 +7,7 @@ div#resume_js_app {
|
|||
font-family: monospace;
|
||||
box-shadow: 0 2px 1px #303030A0;
|
||||
color: #e1e1e1 !important;
|
||||
padding: 2px;
|
||||
padding: 8px 2px;
|
||||
transition: 150ms ease;
|
||||
}
|
||||
div#resume_js_app:hover {
|
||||
|
|
|
@ -15,7 +15,8 @@ export class Console extends React.Component {
|
|||
theme: {
|
||||
background: '#212121',
|
||||
brightGreen: '#15a179'
|
||||
}
|
||||
},
|
||||
convertEol: true
|
||||
}}
|
||||
/>
|
||||
</div>;
|
||||
|
|
|
@ -9,9 +9,9 @@ const fs = require('../fs');
|
|||
module.exports = (argv, terminal) => {
|
||||
if (argv.indexOf('--help') != -1) {
|
||||
terminal.writeln(`Usage: ${argv[0]} [files] [-n]`);
|
||||
terminal.writeln(' -n --number: show lines numbers');
|
||||
terminal.writeln(' --help: show this help');
|
||||
terminal.writeln('Reads file into stdout');
|
||||
terminal.writeln(' -n --number show lines numbers');
|
||||
terminal.writeln(' --help show this help');
|
||||
terminal.writeln('Read files into stdout');
|
||||
return;
|
||||
}
|
||||
const numbers = (argv.indexOf('-n') != -1) || (argv.indexOf('--number') != -1);
|
||||
|
@ -20,11 +20,16 @@ module.exports = (argv, terminal) => {
|
|||
files.shift();
|
||||
files.forEach(file => {
|
||||
const lines = fs.readFileSync(file).toString().split('\n');
|
||||
let i = 1;
|
||||
lines.forEach(line => {
|
||||
if (numbers) terminal.write('\033[35m' + i + ' |\033[0m ');
|
||||
terminal.writeln(line);
|
||||
i++;
|
||||
})
|
||||
|
||||
if (numbers) {
|
||||
lines.forEach((line, i) => {
|
||||
terminal.write('\033[35m' + i + ' |\033[0m ');
|
||||
})
|
||||
} else {
|
||||
terminal.write(file);
|
||||
/// print % if no newline at eof
|
||||
if (lines[lines.length - 1] != '')
|
||||
terminal.write('\033[30;47m%\033[0m\n');
|
||||
}
|
||||
})
|
||||
}
|
|
@ -2,7 +2,9 @@ let cmds = {
|
|||
'cat': require('./cat'),
|
||||
'cmds': require('./cmds'),
|
||||
'cmdls': require('./cmds'),
|
||||
'help': require('./cmds')
|
||||
'help': require('./cmds'),
|
||||
'ls': require('./ls'),
|
||||
'skills': require('./skills')
|
||||
};
|
||||
|
||||
module.exports = cmds;
|
|
@ -0,0 +1,60 @@
|
|||
const { Terminal } = require('xterm');
|
||||
const fs = require('../fs');
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string[]} argv
|
||||
* @param {Terminal} terminal
|
||||
*/
|
||||
module.exports = (argv, terminal) => {
|
||||
if (argv.indexOf('--help') != -1) {
|
||||
terminal.writeln(`Usage: ${argv[0]} [dirs] [-a|--all] [-l]`);
|
||||
terminal.writeln('Lists files in directories');
|
||||
terminal.writeln(' -a --all List all files (including those who start with .)');
|
||||
terminal.writeln(' -l Use long listing format');
|
||||
return;
|
||||
}
|
||||
|
||||
const has_arg = (arg) => {return argv.indexOf(arg) != -1};
|
||||
|
||||
let directories = [...argv];
|
||||
|
||||
const all = (has_arg('-a') || has_arg('--all'));
|
||||
const long_format = has_arg('-l');
|
||||
|
||||
directories.shift();
|
||||
|
||||
// remove .* files if -a not specified
|
||||
if (!all)
|
||||
directories = directories.filter(x => x.startsWith('.'));
|
||||
|
||||
// remove arguments
|
||||
directories = directories.filter(x => !x.startsWith('-'));
|
||||
|
||||
if (directories.length == 0) directories = ['.'];
|
||||
|
||||
// remove dublicates
|
||||
directories = [...new Set(directories)];
|
||||
|
||||
directories.forEach((dir, i) => {
|
||||
|
||||
if (directories.length != 1) {
|
||||
terminal.writeln(dir + ':');
|
||||
terminal.writeln('');
|
||||
}
|
||||
|
||||
let files = fs.readdirSync(dir);
|
||||
files.forEach((file, i) => {
|
||||
|
||||
if (!fs.accessSync(file, fs.constants.X_OK))
|
||||
terminal.write('\033[1;32m');
|
||||
if (fs.accessSync(file, fs.constants.R_OK))
|
||||
terminal.write('\033[35m');
|
||||
|
||||
terminal.write(file + '\033[0m ');
|
||||
if ((i+1) % 5 == 0)
|
||||
terminal.writeln('');
|
||||
});
|
||||
terminal.writeln('');
|
||||
})
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (argv, terminal) => {
|
||||
terminal.write('uwu\nowo\n');
|
||||
}
|
|
@ -4,7 +4,7 @@ div#resume_js_app {
|
|||
background: #212121;
|
||||
border: 1px solid #e1e1e1;
|
||||
border-radius: 6px;
|
||||
padding: 2px;
|
||||
padding: 8px 2px;
|
||||
font-family: monospace;
|
||||
transition: all .15s;
|
||||
box-shadow: 0 2px 1px #303030a0;
|
||||
|
|
Loading…
Reference in New Issue