Create Hyper.app plugins from Hyper.app's configuration file ~/.hyper.js
.
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.
Just add the following properties to your ~/.hyper.js
.
The object containing the properties below:
A boolean value; whether to print to STDOUT
the npm
commands' output.
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.
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 referenceshyper-custom-plugins
'module.exports
. Mutate this object to add other Hyper.app hooks. Overriding thedecorateConfig
property will prevent theconfig.customPlugins.callback
function from running until a new session is created or "Update Plugins" is run. -
config
: The initialconfig
object after it has been decorated by other plugins, unlesshyper-custom-plugins
is the first in theplugins
array inside~/.hyper.js
. Mutate this object to changeconfig
. -
dependencies
: An object with keys that will be the name of thenpm
modules passed inconfig.customPlugins.dependencies
and values that will be thenpm
modules after beingrequire
d. -
module
: A reference tohyper-custom-plugins
'module
object.
-
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' ); }, }, }, };
-
I like to use the theme
hyperterm-material
, but I wish that theconfig.backgroundColor
it sets was slightly transparent! Instead of creating a whole module just for this purpose, I just usehyper-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' ], };