Command line

CommandPrintsChanges the file
mdsh doc.mdProse, code and outputNo
mdsh --hide-code doc.mdProse and outputNo
mdsh --hide-output doc.mdProse and codeNo
mdsh --hide-code --hide-output doc.mdProse only; nothing runsNo
mdsh --no-run doc.md (or -n)Prose, code and the output saved by -w; nothing runsNo
mdsh -n -o view.md doc.mdNothing; saves what -n prints to view.mdNo
mdsh -w doc.mdProgress on stderrYes: output rewritten
mdsh -o out.md doc.mdProgress on stderrNo; writes what -w would to out.md
mdsh --pdf doc.pdf doc.mdNothing; lays out what it would print as doc.pdfNo; with -w or -o it writes those too
mdsh --html doc.html doc.mdNothing; writes what it would print as a standalone doc.htmlNo; with -w or -o it writes those too
mdsh --only build doc.mdThat block, plus what it depends onPer flags
mdsh --yes doc.mdRuns confirm blocks without askingPer flags
mdsh --step doc.mdAsks before every block: run, skip or stopPer flags
mdsh --source defs.zsh doc.mdSources defs.zsh into every shell before its first block; repeatablePer flags
mdsh -i doc.mdA full-screen UI: pick blocks and run them, see Interactive modeYes: output saved after each block
mdsh completion bash|zshA completion scriptNo
mdsh --versionThe versionNo
  • mdsh doc.md is short for mdsh run doc.md, so #!/usr/bin/env mdsh works on Linux and macOS. Arguments after the file name reach blocks as $1, $2 and so on.
  • - reads from stdin: cat doc.md | mdsh -.
  • Execute mode writes to stdout, so mdsh doc.md > report.md gives a rendered report.
  • --pdf respects --hide-code, --hide-output, --only and the rest: the PDF shows what would be printed. --pdf - writes it to stdout. See PDF output for what goes on the page and an example.
  • --html does the same as an HTML page, with local images inside it and raw HTML from the document left out. It can’t be used with --pdf.
  • --source FILE is read once, when mdsh starts, so a pipe works: mdsh --source <(alias -L; typeset -f) doc.md gives blocks the aliases and functions of the shell you run it from. See Environments.
  • Output is styled when stdout is a terminal. --color=never, --no-color or NO_COLOR turn that off.