#
hs.ipc
Provides Hammerspoon with the ability to create both local and remote message ports for inter-process communication.
The most common use of this module is to provide support for the command line tool hs
which can be added to your terminal shell environment with hs.ipc
module is loaded first, so it is recommended that you add require("hs.ipc")
to your Hammerspoon init.lua
file (usually located at ~/.hammerspoon/init.lua) so that it is always available when Hammerspoon is running.
This module is based heavily on code from Mjolnir by Steven Degutis.
#
API Overview
Deprecateds - API features which will be removed in an future release
cliGetColors cliResetColors cliSetColors
Functions - API calls offered directly by the extension
cliColors cliInstall cliSaveHistory cliSaveHistorySize cliStatus cliUninstall
Constructors - API calls which return an object, typically one that offers API methods
localPort remotePort
Methods - API calls which can only be made on an object returned by a constructor
delete isRemote isValid name sendMessage
#
API Documentation
#
Deprecateds
#
cliGetColors
#
cliResetColors
#
cliSetColors
#
Functions
#
cliColors
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.ipc.cliColors([colors]) -> table
|
| Type | Function |
| Description | Get or set the terminal escape codes used to produce colorized output in the hs
command line tool |
| Parameters |
- colors - an optional table or explicit nil specifying the colors to use when colorizing output for the command line tool. If you specify an explicit nil, the colors will revert to their defaults. If you specify a table it must contain one or more of the following keys with the terminal key sequence as a string for the value: initial - this color is used for the initial tagline when starting the command line tool and for output to the Hammerspoon console that is redirected to the instance. Defaults to "\27[35m" (foreground magenta). input - this color is used for input typed in by the user into the cli instance. Defaults to "\27[33m" (foreground yellow). output - this color is used for output generated by the commands executed within the instance and the results returned. Defaults to "\27[36m" (foreground cyan). error - this color is used for lua errors generated by the commands executed within the instance. Defaults to "\27[31m" (foreground red).
- a table describing the colors used when colorizing output in the
hs
command line tool.
- For a brief intro into terminal colors, you can visit a web site like this one http://jafrog.com/2013/11/23/colors-in-terminal.html
- Lua doesn't support octal escapes in it's strings, so use
\x1b
or\27
to indicate theescape
character e.g.ipc.cliSetColors{ initial = "", input = "\27[33m", output = "\27[38;5;11m" }
- Changes made with this function are saved with
hs.settings
with the following labels and will persist through a reload or restart of Hammerspoon: "ipc.cli.color_initial", "ipc.cli.color_input", "ipc.cli.color_output", and "ipc.cli.color_error"