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

hyper-autoprofile

v1.0.4

Published

Extension for Hyper.app to profile term according to shell prompt

Downloads

11

Readme

hyper-autoprofile

CI Status NPM version Downloads Conventional Commits

Extension for Hyper.app to configure terminal appearance according to current shell prompt.

AutoProfile Demo

Install

Using hpm

hpm install hyper-autoprofile

Manually

To install, edit ~/.hyper.js and add "hyper-autoprofile" to plugins:

plugins: [
  "hyper-autoprofile",
],

Configuration

Add autoProfile in your ~/.hyper.js config. The configuration below shows the two differents sections prompts and profiles:

module.exports = {
  config: {
    // other configs...
    autoProfile: {
      prompts: [
        {
          // 'MyHost:Documents me$ ' default MacOS bash prompt
          pattern: "^(\\S+):(.*) ([a-z_][a-z0-9_\\-\\.]*[\\$]?)[\\$#]\\s*$",
          hostname: 1,
          path: 2,
          username: 3
        },
        {
          // 'me@MyHost:~$ ' default Linux bash prompt
          pattern:
            "^([a-z_][a-z0-9_\\-\\.]*[\\$]?)@(\\S+):([\\/~].*)[\\$#]\\s*$",
          username: 1,
          hostname: 2,
          path: 3
        },
        {
          // 'me@MyHost ~> ' default fish prompt
          pattern: "^([a-z_][a-z0-9_\\-\\.]*[\\$]?)@(\\S+) ([\\/~].*)[>#]\\s*",
          username: 1,
          hostname: 2,
          path: 3
        },
        {
          // 'MyHost% ' default zsh prompt
          pattern: "^(\\S+)% ",
          hostname: 1
        },
        {
          // '➜  ~' default oh-my-zsh prompt (robbyrussell theme)
          pattern: "^➜  ([\\/~].*) ",
          path: 1
        },
        {
          // 'me@MyHost MINGW64 ~ (master) ' default git-bash prompt on Windows
          pattern: "^([a-z_][a-z0-9_\\-\\.]*[\\$]?)@(\\S+) MINGW64 ([\\/~].*)(\s|$)",
          username: 1,          
          hostname: 2,          
          path: 3        
        }
      ],
      profiles: [
        {
          triggers: ["root@"],
          backgroundColor: "#400"
        },
        {
          triggers: ["@scotchbox"],
          backgroundColor: "#040"
        },
        {
          triggers: ["/project"],
          backgroundColor: "#004"
        }
      ],
      stripAnsiSequences: true, //default
      debug: false //default
    }
  }
  //...
};

autoProfile.prompts

This section defines different patterns for parsing prompt components: username, host, path.

Note that pattern is a string literal passed to the RegExp() constructor, so remember to escape backslashes in your regexp. For example, if you used a site like regex101.com to verify that your regexp /\[(\w+):\s*(\w+)\](\s*\$)/ is correct, you would double each backslash and write the pattern as:

pattern: '\\[(\\w+):\\s*(\\w+)\\](\\s*\\$)',

The values for hostname, username, and pattern are indexes into the match array returned by RegExp#exec.

For example, define a pattern for MacOS bash default prompt:

{
  // 'MyHost:~ me$ '
  pattern: '^(\\S+):([/~].*) ([a-z_][a-z0-9_\\-\\.]*[\\$]?)[\\$#]\\s*$',
  hostname: 1,
  path: 2,
  username: 3
}

autoProfile.profiles

This section is an ordered array of potential Profile. A Profile is composed by a list of trigger and style properties. trigger formats :

  • 'user@' to specify user
  • '@host' to specify host
  • '/path/to/directory' or '/directory' to specify path
  • 'user@host' to specify user and host
  • 'user@:/path' to specify user and path
  • '@host:/path' to specify host and path
  • 'user@host:/path' to specify user and host and path

user and host components are strictly compared, path matches if it is included in prompt path: '/tmp' path will match '/tmp' and '/path/to/tmp/subpath'.

All other properties of this section will be applied to Term if a trigger is matched. It could be any property of the main config section like backgroundColor, cursorColor, fontSize...

autoProfile.stripAnsiSequences (Default: true)

If enabled, ANSI escape sequences are stripped from input before trying to match triggers. See here for more details.

autoProfile.debug (Default: false)

If enabled, debug information is written to the DevTools console

Caveat

Because of some tricky parsing, this plugin could not detect a shell change immediately. To force its detection, clearing terminal (Ctrl+L) could help.

Licence

MIT