GitXplorerGitXplorer
d

hyper-custom-plugins

public
4 stars
0 forks
1 issues

Commits

List of commits on branch master.
Unverified
023a2eb76cf5a6f51bde1fc9e0e0bf58b8b23712

Update README.md with more examples and links

ddfrankland committed 8 years ago
Unverified
cfd2b224e44c8ffd9cea3c081759dcf9f4b2061a

1.1.2

ddfrankland committed 8 years ago
Unverified
53fa788b5c34daad144b28a297f2db8a061cb0f2

Fix README.md reference to old configuration

ddfrankland committed 8 years ago
Unverified
0e1786698a14a3ef85207666e1f08f20373d05a1

1.1.1

ddfrankland committed 8 years ago
Unverified
8c04df5cfb1f3d231f7a3b84066573f8b385bde0

Fix repo url

ddfrankland committed 8 years ago
Unverified
d429a41d3ed3ddc85d2bf19ac91c843578fcc543

1.1.0

ddfrankland committed 8 years ago

README

The README file for this repository.

hyper-custom-plugins

Create Hyper.app plugins from Hyper.app's configuration file ~/.hyper.js.

Why?

Sometimes all you want is a small change to the configuration or plugins in Hyper.app, but you don't want to have to create a whole plugin for it! This plugin makes it much easier to write mini-plugins that can do anything a normal plugin can do.

How to Use It

Just add the following properties to your ~/.hyper.js.

config.customPlugins

The object containing the properties below:

config.customPlugins.output

A boolean value; whether to print to STDOUT the npm commands' output.

config.customPlugins.dependencies

An optional array of npm module dependencies that will be used in your plugins. These npm modules will be dynamically installed and passed to config.customPlugins.callback afterwards.

config.customPlugins.callback

A function to be stringified and run in a Node.js vm. It will have access to the global variable from hyper-custom-plugins and the object, containing the following properties, as an argument:

  • hooks: An object that references hyper-custom-plugins' module.exports. Mutate this object to add other Hyper.app hooks. Overriding the decorateConfig property will prevent the config.customPlugins.callback function from running until a new session is created or "Update Plugins" is run.

  • config: The initial config object after it has been decorated by other plugins, unless hyper-custom-plugins is the first in the plugins array inside ~/.hyper.js. Mutate this object to change config.

  • dependencies: An object with keys that will be the name of the npm modules passed in config.customPlugins.dependencies and values that will be the npm modules after being required.

  • module: A reference to hyper-custom-plugins' module object.

Examples

  1. Setting the terminal bell sound to be an MP3 file that I sync with hyper-sync-settings would be awesome! So let's do that:

    module.exports = {
      config: {
        bell: 'SOUND',
        bellSoundURL: undefined,
        customPlugins: {
          callback: ({ config, module }) => {
            const homedir = module.require('os').homedir();
            const joinPath = module.require('path').join;
            config.bellSoundURL = joinPath(
              homedir,
              '.hyper_plugins',
              '.hyper-sync-settings',
              'pokemon-rby-level-up.mp3'
            );
          },
        },
      },
    };
  2. I like to use the theme hyperterm-material, but I wish that the config.backgroundColor it sets was slightly transparent! Instead of creating a whole module just for this purpose, I just use hyper-custom-plugins like this:

    module.exports = {
      config: {
        customPlugins: {
          output: false,
          dependencies: ['color'],
          callback: ({ hooks, config, dependencies, module }) => {
            const { color: Color } = dependencies;
            const { backgroundColor } = config;
            const newBackground = Color(backgroundColor).fade(0.3).rgb().string();
            config.backgroundColor = newBackground;
          },
        },
      },
      plugins: [
        'hyperterm-material',
        'hyper-custom-plugins'
      ],
    };