Emacs-esque M-x
commands for your entire OS.
- Recommends
skhd
for hot-key bindings. - Uses
clipboardy
for clipboard interactions. - Uses
choose
for the command picker on macOS.
- macOS
- Linux
- Windows
git clone https://github.com/calebmpeterson/META-x.git
cd META-x
yarn install
brew install font-fira-code
brew install choose-gui
Meta-x needs a hot-key launcher. skhd
is recommended for macOS.
brew install koekeishiya/formulae/skhd
skhd --start-service
# ⌘SPACE to launch Meta-x on the current text selection in the active window
alt - space: EDITOR=code ~/Tools/meta-x/bin/launch
cmd - space: EDITOR=code ~/Tools/meta-x/bin/launch
# CTRL+V to launch clipboard history
ctrl - v: EDITOR=code ~/Tools/meta-x/bin/clipboard-history
Meta-x config is kept in ~/.meta-x/
directory. This makes it easy to keep your config under source control.
All configuration options are contained in ~/.meta-x/config.json
Custom commands are commonjs
modules placed in ~/.meta-x/
.
To get a calculator capable of all operations/syntax available to you in JavaScript, create ~/.meta-x/calc.js
with the following content:
module.exports = (selection) => eval(selection);
To create a command which does not transform the current selection simply return undefined
from the command module's exported function:
module.exports = (selection) => {
// Do something side-effect'ish here
// ...
// The current selection will not be transformed
return undefined;
};
To run a macOS Shortcut with the output of the command:
module.exports = (selection) => {
// The current selection will not be transformed.
//
// Instead, "Your Shortcut" will be run with the
// provided input.
return {
shortcut: "Your Shortcut",
input: selection.toUpperCase(),
};
};
In the event that your query does not match a known command, the raw query string will be passed to ~/.meta-x/fallback-handler.js
if it exists:
module.exports = function (selection, query) {
// Do something with the currently selected
// text and/or the raw query string
};
The fallback-handler
can provide suggestions:
module.exports = (selection, query) => {
// Do something with the currently selected
// text and/or the raw query string
};
module.exports.suggestions = () => {
// The suggestions should be an array of strings
return ["suggestion one", "suggestion two", "suggestion three"];
};
In addition to the selection
, each command function is invoked within the "command context".
The "command context" API includes:
_
the Lodash libraryopen
API ↗get
/put
/post
/patch
/delete
methods fromaxios
↗$
/execa
methods fromexeca
osascript
method from 'run-applescript`ENV
which is loaded from the~/.meta-x/.env
file if it existschoose(['option A', 'option B', 'option C'])
which returns aPromise
that resolves to the selected option orundefined
if nothing was selected.
You can use npm
packages by simply installing them in your ~/.meta-x/
directory.
For example:
> cd ~/.meta-x/
> yarn add lodash
Meta-x is released under the MIT license.
Issues and Pull Requests are welcome!
- Configurable hot-key
- Document usage instructions
- Add built-in commands
- Document installation instructions
- Periodically re-build command catalog in the background rather than re-building when launched
- Add shutdown/restart commands
- Add support for static text snippets