SkillAgentSearch skills...

Termtools

Customize your terminal using JavaScript. With themes, extra alias and functions, we combine the power from both JavaScript and Bash.

Install / Use

/learn @NascHQ/Termtools
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Bash Profile in JavaScript

Easy to customize, built on top of the power of JavaScript and Bash, it adds a bunch of aliases, functions, features and extra funcionality for your bash profile.
The perfect tool to optimize the JavaScript developer command line.

termtools themes NPM Scripts auto completion Termtools with battery, time and read only

Still in alpha version. Looking for tests and feedback :)

Features

  • [x] Fully customizable using JavaScript
  • [x] Applies to PS1
  • [x] Adds auto completion to npm scripts
  • [x] Terminal comands to enable or disable it (restoring your previous PS1)
  • [x] Allows you to dinamically turn on and off parts of PS1
  • [x] PS2 with line numbers
  • [x] Auto completes git commands
  • [x] Shows current branch and git state (also customizable)
  • [x] Lots of Extra aliases (check the aliases section for more info about it)
  • [x] Extra functions
  • [x] Suport themes (coming with 6 themes for you to extend and customize...see below)
  • [x] Move easily from one theme to another
  • [x] Protects some actions (like deleting or change permissions to root path)
  • [x] Auto installs fonts for you (although, you might need to select them in your terminal settings)
  • [x] Ensures colors...everywhere... grep, git, ls...
  • [x] More tools, like time, battery and readOnly...
  • [x] Extendable...you can customize your theme with any extra string, allowing you to use JavaScript to decide what to show
  • [x] Create aditional, customizable parts for $PS1
  • [x] Ignore duplicate commands in history
  • [x] New terminal windows will have the history from brevious bash

Installing it

Easy like sunday morning!

npm install -g @nasc/termtools

Applying it

Run this command and, if everything went well, your terminal should be good looking by now!

termtools apply

This will also install the fonts you will need, if they are not already there.

Oh Oh!

Seing weird characters? No worries, follow the tips your own terminal will give you.
At any time, you can run termtools check to validate the characters and some colors.

The font we are using (and was already installed for you) is:
"Droid Sans Mono for Powerline Plus Nerd File Types Mono"

All you gotta do is go to your terminal settings and edit your profile changing its font face/family to that one.

In Visual Studio Code, you can add the settings for the integrated terminal (ctrl/cmd+",", digite "terminal.integrated.fontFamily" to find it easily):

"terminal.integrated.fontFamily": "Droid Sans Mono for Powerline Plus Nerd File Types Mono"

You should be able to run termtools check and see this message:

Termtools character set test

Removing it (restore)

Want to see your PS1 as it was before (will also loose all the aliases and extra functions we had applied to your bash).

 termtools remove 
 # or
 termtools restore 

To bring it back, just run the apply command again:

 termtools apply 

Reloading it

You will probably not need to reload it anytime soon, but just in case...
After installed and applied, you have three ways to reload it. They will reload the whole bash profile (applying any updates that might be outdated).

# alternative 1
termtools reload
#alternative 2
reload
# alternative 3
termtools restore
termtools apply

CLI options

You can use the cli options following the pattern:

termtools [options]

| Option | Description | |-----------|-----------------------------------------------------------------------------| | help | Shows the help contenbt | | apply | Applies the termtools PS1 effects | | reload | Reloads the bash profile | | restore | Disables termtools effects, restoring your PS1 to what is was before | | customize | Will copy the default theme into your home directory for you to customize it.<br/>BE CAREFUL: It will overwrite your ~/.bash_profile.js if it already exists and you may loose any customization you had applied to it | | set theme | Replaces the current theme with an existing one. Use [tab] to see the list of installed themes.<br/>BE CAREFUL: It will overwrite your ~/.bash_profile.js if it already exists and you may loose any customization you had applied to it | | check | Shows a test block for you to verify if your font family is working ok |

You can hit [tab] for some auto-complete

Git integration

If you are navigating in a directory that happens to belong to a Git Repository, you will see its current branch in your terminal.
Also, the color indicates the current status of your branch and you might see symbols identifying your branch as behind, ahead or diverged.

Termtools default theme

PS2

We also change your PS2 a little, adding line numbers for your multiple lined commands:

Termtools multiline commands with line numbers

Themes

Yes, we deliver termtools with 6 builtin themes, they are:

  • basic
  • default
  • hell
  • sea
  • pinkish
  • round

You can easily move from one theme to another using the command


 termtools set theme [theme-name]
 

Just be careful! It will replace your ~/.bash_profile.js and, if you have done any customization to it, you will loose them.

If you have created a very nice theme and want to share, send us a pull request 😊

Customizing it

You can customize Termtools using JavaScript \o/
And it is not even a JSON, nope...it is JavaScript, indeed 🙏.

We can create a boilerplate for you to customize (a copy of the default theme).
Just run:

 termtools customize

It will create a file at ~/.bash_profile.js.
That file is a copy of our default theme, with comments and all you might need to extend it.
This JavaScript file must export a literal object, or a function that returns a literal object.

If you exported a function, it will be called receiving one parameter, an object with these properties:

| Property | Description | |-------------|:--------------------------------------------------------------------------------------| | IS_TTY | True if current session is running on a TTY environment | | IS_ROOT | True if the current user is root | | IP | The current device's ip | | BATTERY | The current percentage of the battery (give or take...some OSs lie a little about it) | | IS_CHARGING | True if the device is connected and charging | | GIT_STATUS | The repository status. May be from -2 to 5, meaning:<br/>-2: COMMITS DIVERGED<br/>-1: COMMITS BEHIND<br/>0: NO CHANGES<br/>1: COMMITS AHEAD<br/>2: UNTRACKED CHANGES<br/>3: CHANGES TO BE COMMITTED<br/>4: LOCAL AND UNTRACKED CHANGES<br/>5: LOCAL CHANGES | | GIT_SYMBOL | A symbol representing the current position of the branch. Symbols can be: <br/>"-": COMMITS BEHIND<br/>"+": COMMITS AHEAD<br/>"!": COMMITS DIVERGED<br/>"*": UNTRACKED<br/>"": Anything else | | GIT_BRANCH | The name of the current git branch | | IS_WRITABLE | True if the current user has write access to the current directory | | colors | A referece to the a chalk instance, allowing you to add colors if you need to |

Use these data to decide how your exported object will be. You can use it, for example, to enable or disable parts of the $PS1, or to show some parts in different colors.

Check the documentation bellow to understand it better, how to customize your terminal using JavaScript.

After any change you make in your customized theme, you should see the difference just by hitting [ENTER] in your terminal.
If not...you can force it to reload using termtools reload or just the alias reload.

Customization options

You will export a literal object containing these options, or a function that returns such an object. You can extend a given theme, or the default theme will be used.

{
    extends: 'basic'
}

While the default theme will have a PS1 like the second image in this documentation, the basic theme will look like this:

Termtools basic theme

Completition (auto complete)

We will also add auto-complete for your git commands, and add a richer auto-complete for your npm commands as well.
For example, we can hint all the branch names of your repository, or all the scripts from your package.json.

aliases

An object containing the command as the key, and the instruction as the value.
For example:

{
    aliases: {
        foo: "echo bar"
    }
}

Will then, allow you to run in your terminal:

$ foo
bar

Some useful aliases to add, are telated to the the environment you use to work.
For example, let's say you keep all your projects under ~/projects/web/, you can create a alis for going there:

{
    aliases: {
        www: "~/projects/web/"
    }
}

Now, you can type www to go there.

Decorators

This will allow you to customize some of the decorators we will use in your PS1.
So far, they are:

  • pathSeparator
  • section
  • readOnly
  • git

You can use the code (\uCODE) for the following characters (available in the in

Related Skills

View on GitHub
GitHub Stars41
CategoryDevelopment
Updated9mo ago
Forks3

Languages

JavaScript

Security Score

87/100

Audited on Jun 26, 2025

No findings