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

nodeprompt

v2.0.2

Published

A smart Git prompt for your terminal

Downloads

6

Readme

Nodeprompt

npm version Build Status Dependency Status devDependency Status

A smart Git prompt for your terminal powered by Node.js.

Staged, unstaged and untracked files

Requirements

System

  • Bash 3.2.x
  • Fish 2.5.x
  • Zsh 5.3
  • Node.js (tested with 0.10.x, 5.7.x, 6.9.x, 10.x).
  • Git (tested with 1.9.x, 2.7.x, 2.11.x, 2.14.x, 2.25.x).

Note: There is a good change Nodeprompt will work with other configurations — just give it a shot and let me know!

Font

Since v2.0.0 Nodeprompt requires some special (powerline) symbols to be supported by the terminal font to render properly.

Some fonts support those symbols (glyphs) out–of–the–box, for instance, Fira Code used in examples below. Many open–source fonts have been patched and can be downloaded from GitHub. If neither works for you, you can google "[your font name] powerline" because it's likely someone patched your favorite font and posted it on–line.

A note for iTerm 2 users: Make sure the powerline–compatible font is enabled in both Profiles > Text > Font and Profiles > Text > Non–ASCII Font.

Examples

A plain folder (no Git)

A simple folder

An empty Git repository

An empty Git repository

Unstaged changes

Unstaged changes

Staged, unstaged and untracked

Staged, unstaged and untracked files

Branch ahead of the remote

Branch ahead

Merge conflict

Merge conflict

Installation

  1. Call npm install -g nodeprompt (or yarn global add nodeprompt).

  2. Configure your shell:

    Bash

    Put the following line:

    . nodeprompt-enable-bash

    in your ~/.bashrc or ~/.bash_profile file. Re–open the terminal window or source the file, e.g. source ~/.bashrc.

    Zsh

    Put the following lines:

    . nodeprompt-enable-zsh

    in your ~/.zshrc file. Re–open the terminal window or source ~/.zshrc.

    Fish

    Create a symbolic link to the fish_prompt.fish function file:

    ln -s /path/to/../nodeprompt/bin/fish_prompt.fish ~/.config/fish/functions/fish_prompt.fish

    Re–open the terminal window.

  3. Enjoy your beautiful prompt!

Configuration and customization

Nodeprompt is configurable and things like the length of the SHA-1 hash or the number of levels displayed in the path can be adjusted. It is also possible to create a new prompt template from scratch, if that's what you want to do tonight.

Note: You don't have to configure Nodeprompt. By default, it uses config.default.js.

The config file is a plain Node.js module. To configure your prompt, create a ~/.nodeprompt/config.user.js file with module.exports:

module.exports = {
    option: 'value'
};

or simply copy the default configuration and modify it. Refer to the documentation to learn more.

Using as a library

Nodeprompt can be used as a utility to obtain the status of the Git repository. Use the model property to build your own prompt or logger on top of the library:

const Nodeprompt = require( './lib/nodeprompt.js' );
const prompt = new Nodeprompt();

console.log( prompt.model );

> {
	pwd: '/Users/oleq/nodeprompt',
	home: '/Users/oleq',
	gitDir: '.git',
	isGit: true,
	hostname: 'MBP',
	username: 'oleq',
	path: [ '~', 'nodeprompt' ],
	namerev: 'v1.0',
	head: 'ref: refs/heads/v1.0',
	hash: 'b22bb89',
	mergeHead: '',
	isInit: false,
	isBisecting: false,
	isDetached: false,
	isMerging: false,
	modified: 2,
	added: 0,
	untracked: 0,
	ahead: 2,
	behind: 0,
	branch: 'v1.0',
	hasDiverged: false
}

Found a bug?

Create an issue here.

How to contribute?

Clone the repository to /path/to/nodeprompt and put . /path/to/nodeprompt/bin/nodeprompt-bash in your ~/.bashrc or ~/.bash_profile file. Source it or restart the terminal.

License

MIT/X11. See the LICENSE file to know more.

Misc

Kudos to Leonid Volnitsky for git-prompt, an inspiration to create this project.

Tests and development

  • Call npm run test to run tests.
  • Call npm run coverage to run tests with code coverage report in ./coverage.
  • Call npm run lint to run ESLint.