Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Run multiple commands in parallel

License

NotificationsYou must be signed in to change notification settings

pvolok/mprocs

Repository files navigation

mprocs

mprocs runs multiple commands in parallel and shows output of each commandseparately.

When you work on a project you very often need the same list of commands to berunning. For example:webpack serve,jest --watch,node src/server.js.With mprocs you can list these command inmprocs.yaml and run all of them byrunningmprocs. Then you can switch between outputs of running commands andinteract with them.

It is similar toconcurrently butmprocsshows output of each command separately and allows to interact with processes(you can even work invim insidemprocs).

Screenshots

Installation

Packaging status

Download binary (Linux, Macos, Windows)

Download executable for yourplatform and put it into a directory included in PATH.

npm (Linux, Macos, Windows)

npm install -g mprocs
yarn global add mprocs

homebrew (Macos, Linux)

brew install mprocs

cargo (All platforms)

cargo install mprocs

scoop (Windows)

scoop install mprocs

AUR (Arch Linux)

yay mprocs
yay mprocs-bin

MPR (Debian/Ubuntu)

git clone'https://mpr.makedeb.org/mprocs'cd mprocs/makedeb -si

Usage

  1. Runmprocs cmd1 cmd2 … (example:mprocs "yarn test -w" "webpack serve")

OR

  1. Createmprocs.yaml file
  2. Runmprocs command

Examplemprocs.yaml:

procs:nvim:cmd:["nvim"]server:shell:"nodemon server.js"webpack:"webpack serve"tests:shell:"jest -w"env:NODE_ENV:test

Config

JSON/YAML Configuration Schema

There are two kinds of configs: global and local.Global config is loadedfrom~/.config/mprocs/mprocs.yaml (or~\AppData\Roaming\mprocs\mprocs.yaml on Windows).Local configis loaded frommprocs.yaml from current directory (or set via cli argument:mprocs --config ./cfg/mprocs.yaml). Settings in thelocal config overridesettings in theglobal config.

  • procs:object - Processes to run. Only allowed in local config.
    • shell:string - Shell command to run (exactly one ofshell orcmd must be provided).
    • cmd:array - Array of command and args to run (exactly one ofshell orcmd must be provided).
    • cwd:string - Set working directory for the process. Prefix<CONFIG_DIR> will be replaced with the path of the directory where theconfig is located.
    • env:object<string, string|null> - Set env variables. Object keys arevariable names. Assign variable to null, to clear variables inherited fromparent process.
    • add_path:string|array - Add entries to thePATHenvironment variable.
    • autostart:bool - Start process when mprocs starts. Default:true.
    • autorestart:bool - Restart process when it exits. Default: false. Note: If process exits within 1 second of starting, it will not be restarted.
    • stop:"SIGINT"|"SIGTERM"|"SIGKILL"|{send-keys:array}|"hard-kill" -A way to stop a process (usingx key or when quitting mprocs).
  • hide_keymap_window:bool - Hide the pane at the bottom of the screenshowing key bindings.
  • mouse_scroll_speed:integer - Number of lines to scrollper one mousescroll.
  • scrollback:integer - Scrollback size. Default:1000.
  • proc_list_width:integer - Process list window width.
  • keymap_procs:object - Key bindings for process list. SeeKeymap.
  • keymap_term:object - Key bindings for terminal window. SeeKeymap.
  • keymap_copy:object - Key bindings for copy mode. SeeKeymap.

Keymap

Default key bindings can be overridden in config usingkeymap_procs,keymap_term, orkeymap_copy fields. Available commands are documented intheRemote control section.

There are three keymap levels:

  • Default keymaps
  • ~/.config/mprocs/mprocs.yaml (or~\AppData\Roaming\mprocs\mprocs.yaml on Windows)
  • ./mprocs.yaml (can be overridden by the-c/--config cli arg)

Lower levels override bindings from previous levels. Key bindings from previouslevels can be cleared by specifyingreset: true field at the same level askeys.

Key bindings are defined between< and>, e.g.,<Enter> (enter key),<Down> (down arrow),<Up> (up arrow),<C-q> (CTRL + q).

keymap_procs:# keymap when process list is focused<C-q>:{ c: toggle-focus }<C-a>:null# unbind keykeymap_term:# keymap when terminal is focusedreset:true<C-q>:{ c: toggle-focus }<C-j>:c:batchcmds:      -{ c: focus-procs }      -{ c: next-proc }

$select operator

You can define different values depending on the current operating system. Anyvalue in config can be wrapped with a$select operator. To provide differentvalues based on current OS define an object with:

  • First field$select: os
  • Fields defining values for different OSes:macos: value. Possiblevalues 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 forcurrent OS. If current OS is not matched and field$else is missing, thenmprocs will fail to load config.

Examplemprocs.yaml:

procs:my process:shell:$select:oswindows:"echo %TEXT%"$else:"echo $TEXT"env:TEXT:$select:oswindows:Windowslinux:Linuxmacos:Macosfreebsd:FreeBSD

Running scripts from package.json

If you runmprocs with an--npm argument, it will load scripts frompackage.json. But the scripts are not run by default, and you can launchdesired scripts manually.

# Run mprocs with scripts from package.jsonmprocs --npm

Default keymap

Process list focused:

  • q - Quit (soft kill processes and wait then to exit)
  • Q - Force quit (terminate processes)
  • C-a - Focus output pane
  • x - 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 running
  • r - Soft kill selected process and restart it when it stops
  • R - Hard kill selected process and restart it when it stops
  • a - Add new process
  • C - Duplicate selected process
  • d - Remove selected process (process must be stopped first)
  • e - Rename selected process
  • k or - Select previous process
  • j or - Select next process
  • M-1 -M-8 - Select process 1-8
  • C-d orpage down - Scroll output down
  • C-u orpage up - Scroll output up
  • C-e - Scroll output down by 3 lines
  • C-y - Scroll output up by 3 lines
  • z - Zoom into terminal window
  • v - Enter copy mode

Process output focused:

  • C-a - Focus processes pane

Copy mode:

  • v - Start selecting end point
  • c - Copy selected text
  • Esc - Leave copy mode
  • C-a - Focus processes pane
  • C-d orpage down - Scroll output down
  • C-u orpage up - Scroll output up
  • C-e - Scroll output down by 3 lines
  • C-y - Scroll output up by 3 lines
  • k or - Move cursor up
  • l or - Move cursor right
  • j or - Move cursor down
  • h or - Move cursor left

Remote control

Optionally,mprocs can listen on TCP port for remote commands.You have to define remote control server address inmprocs.yaml(server: 127.0.0.1:4050) or via cli argument (mprocs --server 127.0.0.1:4050). To send a command to runningmprocs instanceuse thectl argument:mprocs --ctl '{c: quit}' ormprocs --ctl '{c: send-key, key: <C-c>}'.

Commands are encoded as yaml. Available commands:

  • {c: quit-or-ask} - Stop processes and quit. If any processes are running,show a confirmation dialog.
  • {c: quit} - Stop processes and quit. Does not show confirm dialog.
  • {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: zoom} - Zoom into terminal window
  • {c: next-proc}
  • {c: prev-proc}
  • {c: select-proc, index: <PROCESS INDEX>} - Select process by index, top process has index 0
  • {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>", name: "<PROC NAME>"} - Add proccess.name field is optional.
  • {c: duplicate-proc}
  • {c: show-remove-proc}
  • {c: remove-proc, id: "<PROCESS ID>"}
  • {c: show-rename-proc}
  • {c: rename-proc, name: "<NEW_NAME>"} - Rename currently selected process
  • {c: scroll-down}
  • {c: scroll-up}
  • {c: scroll-down-lines, n: <COUNT>}
  • {c: scroll-up-lines, n: <COUNT>}
  • {c: copy-mode-enter} - Enter copy mode
  • {c: copy-mode-leave} - Leave copy mode
  • {c: copy-mode-move, dir: <DIRECTION> } - Move starting or ending positionof the selection. Available directions:up/right/down/left.
  • {c: copy-mode-end} - Start selecting end point of the selection.
  • {c: copy-mode-copy} - Copy selected text to the clipboard and leave copymode.
  • {c: send-key, key: "<KEY>"} - Send key to current process. Key examples:<C-a>,<Enter>
  • {c: batch, cmds: [{c: focus-procs}, …]} - Send multiple commands

FAQ

mprocs vs tmux/screen

mprocs is meant to make it easier to run specific commands that you end uprunning repeatedly, such as compilers and test runners. This is in contrastwithtmux, which is usually used to run much more long-lived processes -usually a shell - in each window/pane. Another difference is thattmux runs aserver and a client, which allows the client to detach and reattach later,keeping the processes running.mprocs is meant more for finite lifetimeprocesses that you keep re-running, but whenmprocs ends, so do the processesit is running within its windows.

Copying doesn't work in tmux

Tmux doesn't have escape sequences for copying enabled by default. To enable itadd the following to~/.tmux.conf:

set -g set-clipboard on

About

Run multiple commands in parallel

Topics

Resources

License

Stars

Watchers

Forks

Contributors29

Languages


[8]ページ先頭

©2009-2025 Movatter.jp