Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ Learn more about Docker [here](https://docs.docker.com/get-started/overview/ 'he
"github": // your handle
"linkedin": // your handle
},
"excluded_commands": [
// list of commands you would like to exclude
"command_1",
"command_n"
],
"email": // your email
"ps1_hostname": "liveterm" // hostname in prompt
"ps1_username": "visitor", // username in prompt
Expand Down
2 changes: 2 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"paypal": "https://paypal.me/cveinnt",
"patreon": "https://patreon.com/cveinnt"
},
"excluded_commands": [
],
"colors": {
"light": {
"background": "#FBF1C9",
Expand Down
3 changes: 2 additions & 1 deletion src/components/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { commandExists } from '../utils/commandExists';
import { shell } from '../utils/shell';
import { handleTabCompletion } from '../utils/tabCompletion';
import { Ps1 } from './Ps1';
import { commandExclude } from '../utils/commandExclude';

export const Input = ({
inputRef,
Expand Down Expand Up @@ -89,7 +90,7 @@ export const Input = ({
id="prompt"
type="text"
className={`bg-light-background dark:bg-dark-background focus:outline-none flex-grow ${
commandExists(command) || command === ''
(commandExists(command) || command === '') && !commandExclude(command)
? 'text-dark-green'
: 'text-dark-red'
}`}
Expand Down
13 changes: 9 additions & 4 deletions src/utils/bin/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@

import * as bin from './index';
import config from '../../../config.json';
import { commandExclude } from '../commandExclude';

// Help
export const help = async (args: string[]): Promise<string> => {
const commands = Object.keys(bin).sort().join(', ');
var c = '';
var included_count = 1;
for (let i = 1; i <= Object.keys(bin).sort().length; i++) {
if (i % 7 === 0) {
c += Object.keys(bin).sort()[i - 1] + '\n';
} else {
c += Object.keys(bin).sort()[i - 1] + ' ';
if (!(commandExclude(Object.keys(bin).sort()[i-1]))){
if (included_count % 7 === 0) {
c += Object.keys(bin).sort()[i - 1] + '\n';
} else {
c += Object.keys(bin).sort()[i - 1] + ' ';
}
included_count++;
}
}
return `Welcome! Here are all the available commands:
Expand Down
7 changes: 7 additions & 0 deletions src/utils/commandExclude.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import config from '../../config.json';

var exception_commands = [ 'banner' , 'help' ]

export const commandExclude = (command: string) => {
return config.excluded_commands.includes(command) && !(exception_commands.includes(command))
}
3 changes: 2 additions & 1 deletion src/utils/shell.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import * as bin from './bin';
import { commandExclude } from '../utils/commandExclude';

export const shell = async (
command: string,
Expand All @@ -14,7 +15,7 @@ export const shell = async (
clearHistory();
} else if (command === '') {
setHistory('');
} else if (Object.keys(bin).indexOf(args[0]) === -1) {
} else if (Object.keys(bin).indexOf(args[0]) === -1 || commandExclude(args[0])) {
setHistory(
`shell: command not found: ${args[0]}. Try 'help' to get started.`,
);
Expand Down