1.0.13 • Published 1 year ago

rbash v1.0.13

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

rbash

Badge Name

A customizable React component that renders a terminal-like interface. It supports various built-in commands like ls, help, clear, while also providing an interface for custom commands.

Usage

To use the rbash in your React project, you can install it from NPM by running npm install rbash and importing it:

import { Terminal } from 'rbash/main';

function App() {
  return (
    <div>
      <Terminal />
    </div>
  );
}

Props

The <Terminal /> component has 6 props that can all be edited:

  • branch = randomBranch() // if no branch is passed a random one will be selected
  • dirs = ["pass", "in", "your", "custom", "dirs"], // default list of directories
  • cwd = "/rbash", // current working directory
  • commands = {}, // custom commands
  • bgColor = "#1e1e1e", // background color of terminal body
  • color = "White", // font color

It also has some built in commands:

builtInCommands = {
    clear: { cmd: "clear/cls", output: null, def: "clears terminal" },
    help: { cmd: "help", output: null, def: "shows list of available commands"},
    pwd: {cmd: "pwd", output: cwd, def: "outputs current working directory"},
    ls: {cmd: "ls", output: null, def: "lists contents of current working directory"},
    ...commands,
},

Note that while you can alter the builtInCommands it is not advisable to do so.

If you click the red button the terminal will close and a small icon will appear in the bottom-left of the screen in a fixed position. To reopen the terminal just click on the icon.

Note (2) that closing the terminal will erase current line.

Adding Custom Commands

To add custom commands, pass an object to the commands prop with the command name as the key and an object with the following properties as the value:

import Terminal from 'rbash/main';

function App() {
  const customCommands = {
    hello: {
      cmd: 'hello',
      def: 'Says hello to the user',
      output: 'Hello!',
    },
  };

  return (
    <div>
      <Terminal commands={customCommands} />
    </div>
  );
}

Themes

There are a variety of built-in color themes to choose from. Apply a theme by passing the theme name as a prop (string) to the component. If a theme is not specified, the component will default to the default theme:

  • default
  • aqua
  • aurora
  • cafe
  • candy
  • cobalt
  • coral
  • galaxy
  • iris
  • mango
  • ocean
  • orchid
  • peacock
  • plum
  • rust
  • sage
  • tangerine
  • teal
  • wine

If you pass a theme as well as bgColor and color props, the theme will overide the other props. If, however, the theme is misspelled, the other props will take effect.

Contributing

Bug reports and pull requests are welcome, feel free to contribute in any you can.

1.0.2

1 year ago

1.0.1

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.0

1 year ago