npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-mac-terminal

v1.0.2

Published

A customizable React component that renders a terminal-like interface with built in commands, customizable themes and branches, and much more.

Downloads

2

Readme

react-mac-terminal

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 react-mac-terminal in your React project, you can install it from NPM by running npm install react-mac-terminal and importing it:

import { Terminal } from 'react-mac-terminal/main';

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

Props

The <Terminal /> component has 9 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 = "/react-mac-terminal", // current working directory
  • commands = {}, // custom commands
  • bgColor = "#1e1e1e", // background color of terminal body
  • color = "White", // font color
  • draggable = true, // allows terminal to be dragged
  • noFirstLine = false // removes first line completely
  • customFirstLines = '', // lines will be added after date/time line

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 'react-mac-terminal/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.