mprocs runs multiple commands in parallel and shows output of each command separately.
When you work on a project you very often need the same list of commands to be
running. For example: webpack serve
, jest --watch
, node src/server.js
.
With mprocs you can list these command in mprocs.yaml
and run all of them by
running mprocs
. Then you can switch between outputs of running commands and
interact with them.
It is simmilar to concurrently but mprocs shows output of each command separately and allows to interact with processes (you can even work in vim inside mprocs).
Download executable for your platform and put it into a directory included in PATH.
npm install -g mprocs
yarn global add mprocs
brew install pvolok/mprocs/mprocs
cargo install mprocs
scoop install https://raw.githubusercontent.com/pvolok/mprocs/master/scoop/mprocs.json
yay mprocs
yay mprocs-bin
- Run
mprocs cmd1 cmd2 …
(example:mprocs "yarn test -w" "webpack serve"
)
OR
- Create
mprocs.yaml
file - Run
mprocs
command
Example mprocs.yaml
:
procs:
nvim:
cmd: ["nvim"]
server:
shell: "nodemon server.js"
webpack: "webpack serve"
tests:
shell: "jest -w"
env:
NODE_ENV: test
- procs: object - Processes to run.
- shell: string - Shell command to run (only shell or cmd must be provided).
- cmd: array - Array of command and args to run (only shell or cmd must be provided).
- cwd: string - Set working directory for the process. Prefix
<CONFIG_DIR>
will be replaced with the path of the directory where the config is located. - env: object<string, string|null> - Set env variables. Object keys are variable names. Assign variable to null, to clear variables inherited from parent process.
- stop: "SIGINT"|"SIGTERM"|"SIGKILL"|{send-keys: array}|"hard-kill" -
A way to stop a process (using
x
key or when quitting mprocs).
Key bindings can be overridden globally in file ~/.config/mprocs/mprocs.yaml
or in a local config (mprocs.yaml
in current directory by default). Keymaps are separate for process list and terminal windows.
There are three keymap levels:
- Default keymaps
~/.config/mprocs/mprocs.yaml
./mprocs.yaml
(can be overridden by the -c/--config cli arg)
Lower levers override bindings from previous levels. Key bindings from previous
levels can be cleared by specifying reset: true
field at the same level as
keys:
keymap_procs: # keymap when process list is focused
<C-q>: { c: toggle-focus }
keymap_term: # keymap when terminal is focused
reset: true
<C-q>: { c: toggle-focus }
You can define different values depending on the current operating system. To provide different values based on current OS define an object with:
- First field
$select: os
- Fields defining values for different OSes:
macos: value
. Possible values are listed here: https://doc.rust-lang.org/std/env/consts/constant.OS.html. - Field
$else: default value
will be matched if no value was defined for current OS. If current OS is not matched and field$else
is missing, then mprocs will fail to load config.
Example mprocs.yaml
:
procs:
my processs:
shell:
$select: os
windows: "echo %TEXT%"
$else: "echo $TEXT"
env:
TEXT:
$select: os
windows: Windows
linux: Linux
macos: Macos
freebsd: FreeBSD
Process list focused:
q
- Quit (soft kill processes and wait then to exit)Q
- Force quit (terminate processes)C-a
- Focus output panex
- Soft kill selected process (send SIGTERM signal, hard kill on Windows)X
- Hard kill selected process (send SIGKILL)s
- Start selected process, if it is not runningr
- Soft kill selected process and restart it when it stopsR
- Hard kill selected process and restart it when it stopsa
- Add new processd
- Remove selected process (process must be stopped first)k
or↑
- Select previous processj
or↓
- Select next processM-1
-M-8
- Select process 1-8C-d
orpage down
- Scroll output downC-u
orpage up
- Scroll output up
Process output focused:
C-a
- Focus processes pane
Optionally, mprocs can listen on TCP port for remote commands.
You have to define remote control server address in mprocs.yaml
(server: 127.0.0.1:4050
) or via cli argument (mprocs --server 127.0.0.1:4050
). To send a command to running mprocs instance
use the ctl argument: mprocs --ctl '{c: quit}'
or mprocs --ctl '{c: send-key, key: <C-c>}'
.
Commands are encoded as yaml. Available commands:
{c: quit}
{c: force-quit}
{c: toggle-focus}
- Toggle focus between process list and terminal.{c: focus-procs}
- Focus process list{c: focus-term}
- Focus process terminal window{c: next-proc}
{c: prev-proc}
{c: select-proc, index: <PROCESS INDEX>}
- Select process by index{c: start-proc}
{c: term-proc}
{c: kill-proc}
{c: restart-proc}
{c: force-restart-proc}
{c: show-add-proc}
{c: add-proc, cmd: "<SHELL COMMAND>"}
{c: show-remove-proc}
{c: remove-proc, id: "<PROCESS ID>"}
{c: scrol-down}
{c: scroll-up}
{c: send-key, key: "<KEY>"}
- Send key to current process. Key examples:<C-a>
,<Enter>