Just a minimal library to do some terminal stuff.

Related tags

Command Line termctl
Overview

Termctl

A simple library to do some basic terminal stuff.

Screenshot

Usage

const termctl = require("termctl");

Note: We have tested this on Linux Mint and Windows 10 but we don't know if changing colors will work on Mac.

Methods

Input/Output

  • You need to call init() method once before using gets() because termctl uses Node.js's readline module, so init() will be used to create an instance of readline.Interface.

    termctl.init();
  • gets() is used to take user input from the terminal (stdin). First argument is the prompt message to be displayed. Second argument specifies whether to print what user is typing (echo). It's default value is true.

    // termctl.gets(query?: string, echo?: boolean) => Promise<any>
    
    const uname = await termctl.gets("Enter your name: ");
    const pswd = await termctl.gets("Enter password: ", false);
  • Call close() to close the readline.Interface instance.

    termctl.close();

Styling

  • Set background color

    // termctl.color.set_bg(r: number, g: number, b: number): void
    
    termctl.color.set_bg(255, 255, 100);
    
    // (or) css style hex colors
    termctl.color.set_bg(0xFFFF64); // 0xRRGGBB format
  • Reset background color to default

    // termctl.color.reset_bg(): void
    
    termctl.color.reset_bg();
  • Set foreground color

    // termctl.color.set_bg(r: number, g: number, b: number): void
    
    termctl.color.set_fg(0, 0, 0);
    
    // (or) css style hex colors
    termctl.color.set_fg(0x000000); // 0xRRGGBB format
  • Reset foreground color to default

    // termctl.color.reset_bg(): void
    
    termctl.color.reset_fg();
  • Bold

    // termctl.set_bold(bold?: boolean): void
    
    termctl.color.set_bold();
  • Italic

    // termctl.set_italic(italic?: boolean): void
    
    termctl.color.set_italic();
  • Underline

    // termctl.set_underline(underline?: boolean): void
    
    termctl.color.set_underline();
  • Resets all styles to default

    // termctl.color.reset_styles(): void
    
    termctl.color.reset_styles();

Note: We are just using escape sequences inside these methods for changing styles. So resetting styles before exiting is always a good idea.

You might also like...

Display images in the terminal

Display images in the terminal

terminal-image Display images in the terminal Works in any terminal that supports colors. In iTerm, the image will be displayed in full resolution, si

Dec 25, 2022

:rainbow: Beautiful color gradients in terminal output

:rainbow:  Beautiful color gradients in terminal output

gradient-string Beautiful color gradients in terminal output Install $ npm i gradient-string Usage const gradient = require('gradient-string'); cons

Jan 3, 2023

Create clickable links in the terminal

Create clickable links in the terminal

terminal-link Create clickable links in the terminal Install $ npm install terminal-link Usage import terminalLink from 'terminal-link'; const link

Dec 31, 2022

Reliably get the terminal window size

term-size Reliably get the terminal window size Because process.stdout.columns doesn't exist when run non-interactively, for example, in a child proce

Oct 11, 2022

Truncate a string to a specific width in the terminal

cli-truncate Truncate a string to a specific width in the terminal Gracefully handles ANSI escapes. Like a string styled with chalk. It also supports

Oct 10, 2022

Execute shell commands in terminal

Execute shell commands in terminal

Execute shell commands in terminal

Dec 11, 2021

Add a hungry turtle to your terminal and feed it every time you mistype 'npm' as 'nom'

Add a hungry turtle to your terminal and feed it every time you mistype 'npm' as 'nom'

Nom Does this ever happen to you? You happily code away on a project, navigating the command line like a pro, testing, error logging, installing packa

Apr 26, 2022

A terminal for a more modern age

A terminal for a more modern age

Downloads: Latest release Repositories: Debian/Ubuntu-based, RPM-based Latest nightly build This README is also available in: Korean 简体中文 Tabby (forme

Dec 30, 2022

DataENV is a cli tool that allows you to save data temporarily using your terminal.

DataEnv CLI Instllation npm install -g dataenv Usage Table of Contents LocalStorage npx dataenv save Parameters npx dataenv show Parameters npx dataen

Feb 5, 2022
Comments
Owner
Biraj
Just a curious person who is becoming better every day.
Biraj
Terminal ui for discord with interactive terminal

dickord why No fucking clue i was bored or something. why does it look dogshit Try and find a node module that supports terminal functions like trauma

Hima 3 Nov 7, 2022
Sublime-like terminal-based text editor

slap ?? slap is a Sublime-like terminal-based text editor that strives to make editing from the terminal easier. It has: first-class mouse support (ev

slap 6.1k Jan 1, 2023
A terminal-to-gif recorder minus the headaches.

ttystudio A terminal-to-gif recorder minus the headaches. Record your terminal and compile it to a GIF or APNG without any external dependencies, bash

Christopher Jeffrey (JJ) 3.2k Dec 23, 2022
rtail(1) - Terminal output to the browser in seconds, using UNIX pipes.

rtail(1) Terminal output to the browser in seconds, using UNIX pipes. rtail is a command line utility that grabs every line in stdin and broadcasts it

Kilian Ciuffolo 1.6k Jan 6, 2023
Pipeable javascript. Quickly filter, map, and reduce from the terminal

Pipeable JavaScript - another utility like sed/awk/wc... but with JS! Quickly filter, map and reduce from the command line. Features a streaming API.

Daniel St. Jules 410 Dec 10, 2022
Translations with speech synthesis in your terminal as a node package

Normit Normit is an easy way to translate stuff in your terminal. You can check out its Ruby gem version termit. Installation npm install normit -g Us

Paweł Urbanek 234 Jan 1, 2023
Terminal recorder: Record your termial session into HTML

terminal-recorder Terminal recorder allows you to record your bash session, and export it to html so then you can share it with your friends. GitHub P

Cristian Cortez 104 Mar 3, 2022
Terminal task list

listr Terminal task list Install $ npm install --save listr Usage const execa = require('execa'); const Listr = require('listr'); const tasks = new

Sam Verschueren 3.1k Jan 3, 2023
📜 Create mutable log lines into the terminal, and give life to your logs!

Because Logging can be pretty and fun Installation $ npm install draftlog What it does It allows you to re-write a line of your log after being writt

Ivan Seidel 1.2k Dec 31, 2022