README
¶
mdsh-gui
A desktop window for mdsh, built with Wails v3.
It shows a markdown file, runs its sh and zsh blocks as you pick
them, streams their output under them and saves it back to the file. It
uses the same run.Session as mdsh -i.
See the design for how it works and what comes next.
mdsh-gui [flags] [file.md [args...] | folder]
Flags come before the file, as with mdsh; mdsh-gui --help lists them.
--source FILE (repeatable) sources a file into every shell of every
file opened, before its first block. It's read once at startup, so
mdsh-gui --source <(alias -L; typeset -f) notes.md gives blocks the
calling shell's aliases and functions. --only, --step and
--stop-on-error set the Run Options of the file named on the command
line.
With no file, the start screen lists the markdown files under the current
folder, or under folder when one is given (or the start folder from Settings, when started from Finder or
the Dock) to pick from, with the description from each file's front
matter (description, else summary, else abstract) under its name.
A folder with a .mdsh.yaml shows as a collection, with its own title,
icon, color, background and tags (see Collections).
The pin at the end of a file's row pins it to a Pinned list at the top,
above Recent, until its pin is clicked again. Pins are kept in the
settings file with the recent files.
Each file opens in a tab of its own, with its own shells.
- Tabs: New Tab (cmd/ctrl+T, or the + in the tab bar) opens the start screen; Open…, Open Recent and dropped files open in a new tab. Drag a tab to reorder it, onto another window's tab bar or page to move it there, or onto its own page, or out of every window, for a window of its own. Dropped on another app that takes text, such as a terminal or an editor, it gives the file's full path (or, for a document built into the app, its URL) and stays where it is. A block running in it carries on. Close Tab (cmd/ctrl+W, the ×, or a middle click) closes it, and the window goes with its last tab. View › Show Next Tab and Show Previous Tab (cmd/ctrl+shift+] and [) move between them.
- Window sizes: a file that opens in a window of its own, or in a window showing only the start screen, gets the size its window had last, and on macOS and Windows its place too. Opening it in a tab beside others leaves the window as it is. These are kept in the settings file, not in the markdown.
- Sessions: New Session on the start screen opens the day's file,
such as
2026-11-02.md, in the sessions folder (~/.mdsh/sessionsunless Settings › Files names another), making it the first time as a copy of the session template, or with the date as its heading and your login shell ($SHELL, if zsh or bash) as itsshell:. Last Session opens the file in that folder changed last. Either one opens with the History pane open and the keyboard in it. - File: New File… (cmd/ctrl+N, or New File… on the start screen)
offers the templates in the templates folder from Settings, if one
is set, then asks where to save the file and opens it. Without a
template, a new file starts with a heading named for it. New Tab, New Window (cmd/ctrl+shift+N), Open…, Open Recent, Save, Save As…,
Create Report…, Reload, Close Tab and Close Window (cmd/ctrl+shift+W). Create Report… writes a PDF, HTML
or markdown copy, with or without code and output, from the tab's
run, a run of every block or the saved file, and shows the
mdshcommand that makes the same one. Dropping a markdown file on a window opens it. A • marks output that isn't saved, and closing or quitting asks first. - Run: Run Current Block (cmd/ctrl+enter: the block the source
view's cursor is in, or the selected card without the source view),
Run Section (cmd/ctrl+shift+enter: the section of the selected
heading, or the one the source view's cursor or the selected card is
in), Run All (cmd/ctrl+R, the toolbar button turns into Stop while
blocks run), Stop (cmd/ctrl+.), Clear All Outputs… (cmd/ctrl+alt+K,
or the toolbar's eraser button) and Run Options… for the file's
arguments,
--only, step mode and stop on error. Clear All Outputs is off while there is no output to clear. It asks first, then takes every block's output, output copy and stored block value out of the document and forgets what ran; the shells keep what blocks set in them. It isn't saved until you save; with the source view open, undo there brings the output back. The app never ends a shell without asking. Stop, and a block'stimeout=, interrupt the block, as ctrl+c would, and its shell lives on with the variables, functions and aliases blocks set. A block still running three seconds after Stop, such as a loop that ignores ctrl+c, gets a question: Kill Shell ends it, and its shell. Restart Shells (the ↻ in the History bar) asks first too. New arguments in Run Options are set in the shells as they are. Clear All Outputs, Reload and Save As keep the shells. What needs new shells, a newshell:in the front matter or the firstttyblock, waits for Restart Shells, and the History pane, which needs shells on a terminal, asks before starting them again. A block that runsexitstill ends its own shell. A block markedttyruns in a terminal in its card: type at it as you would in a terminal. It is as wide as the card and 24 lines high, unlesscols:androws:underterminal:in the front matter say otherwise. When it ends the card shows the recording, asmdshsaves it. A block markedbackgroundstarts and lets other blocks run: its card has a dashed edge and says it is running in the background, the status line counts them, and its output shows when it ends. Closing the window kills those still running. A block marked bothbackgroundandttyruns in a terminal in its card while other blocks run, such as an editor open on a script the next block runs: it takes the keys as it starts, and a click in its terminal gives them back to it. It isn't stopped at the end of a run, and its card shows the recording once it ends. A running block's card has a spinner and a timer that counts up by tenths of a second, so a long block plainly hasn't hung; a block withtimeout=shows its time against the timeout, as12.3s / 1m, with a bar under its head that fills toward it, turning amber at three quarters and red at nine tenths. When it ends the card keeps how long it took, or says it timed out. - Console (View › Console, cmd/ctrl+shift+Y, or the toolbar's
console button): what the app logs, errors and notes, each with its
time and level, such as a call that failed because the file no longer
parses. A badge on the button counts warnings and errors that came
while it was closed. Copy takes the selected lines, or all of them;
Clear empties it in every window. Drag its top edge to resize it.
A warning an edit fixed stays, struck through and marked "(fixed)".
A warning with a plain fix has a Fix button, in a tab showing its
file: an output copy whose
for=names no block is deleted, and an id in adepends=that names no block that runs is taken out. Fix says what it will do and asks first; Edit › Undo takes it back. Code in the app reports to it by logging withlog/slog. Its Events tab shows the tab's file's event log, the same eventsmdsh --auditwrites, in words: the shells starting and ending, and why, blocks starting, ending and being skipped, the file changing on disk and being reloaded, andmdsh ctlcalls. An event that cost the shells what blocks set in them (a block'sexit, Kill Shell, a shell found dead, Restart Shells) is in bold, counts toward the badge and shows in the status line. Copy there copies the events as JSON lines. The log keeps the last 2,000 events, and lasts as long as the file is open in the tab, reloads included. Its Processes tab shows what runs under the tab's shells, as a tree read frompsevery second while it shows: the block running, background blocks, named by their block, and whatever a block or History left running. Each line says how long the process has run and has a Kill button, which ends it and what it started; a shell itself is only ended by Restart Shells. - History (View › History, cmd/ctrl+shift+H): a terminal along the
bottom that works like a paper tape. Closed, it is a status bar with
the shell's prompt, the status, and buttons to stop (ctrl+c for a
command typed in the pane), start the shells again (it asks first),
and open it, when
the terminal slides up out of the bar. Type a command and press enter:
it runs in the file's shell, sharing variables and the working
directory with the blocks (while it runs the prompt dims and shows how
long it has run, and the input keeps the keyboard, so what you type
meanwhile waits there for the next command), and is added to the end of the file as a
block,
#history-1 skip links,#history-2 skip links…, with its output and exit status, failures included.skipkeeps Run all from running it again, though its play button still does.linksmakes the web addresses it prints (http:,https:andmailto:only) clickable in the block's output, and they are in the pane too; take it off the block to turn them off, or add it to any block. It runs on a real terminal, so you can type at a prompt it shows, and a full-screen program such asviortopis kept as attyblock with its recording. A line starting with#is added as prose, without the#; notes typed one after another make one paragraph. Shift+enter starts another line, and so does enter on an unfinished command, such as one ending in\or inside quotes. Up and down recall what you typed, and the input takes a shell's emacs keys: ctrl+a/e to the line's start or end, ctrl+b/f and alt+b/f by character or word, ctrl+w, alt+backspace, alt+d, ctrl+u and ctrl+k to kill, ctrl+y to yank it back, ctrl+d to delete (or close the pane when nothing is typed), ctrl+p/n for earlier commands and ctrl+l to clear the transcript. The record button, a dot beside Stop, turns recording off: commands typed then still run in the document's shell, so acdor a variable carries over, but aren't added to the file. Notes and typed blocks are still added. The ring without its dot says recording is off; pressing it again, or closing the pane, turns it back on. Tab completes a command, a file or a$variable, as the shell sees them: in its directory, with what blocks set. The prompt is the shell's ownPS1, expanded as the shell would (zsh's%escapes andprecmdhooks, bash's\escapes), withPS2on continuation lines, or$if it has none. Drag over the transcript to select lines and press cmd+c (ctrl+c on Linux and Windows), or right-click for Copy and Select All: they are copied as text, without colors. With lines selected, ctrl+c copies them rather than reaching a command that runs in the pane. The separator over the input shows the shell's working directory (~for your home folder), asked for with the prompt, so it follows acdin the pane or in a block. The button with the two arrows, beside the one that closes the pane, has the pane fill the tab, up to the tab bar, in place of the toolbar and the document; it gives them their place back when pressed again or when the pane closes. The shells aren't interactive, so they don't read your rc file themselves: name it, such as~/.zshrc, in Settings › File the History pane's shell reads, and the shells read it when History is turned on, for your aliases, functions and prompt. With Settings › Run a repeated History command in its block on (it's off by default), a command that has a#history-Nblock already runs that block again, which gainshistoryand keeps its last output as an earlier run, rather than adding another block. ctrl+Z stops a command and ends its block with the stop status;jobs,fgandbgthen work as in a terminal, in shells that allow it, such as dash, theshof Debian and Ubuntu (bash and zsh have no job control unless interactive, so there ctrl+Z is ignored). A command ending in a lone&is added as abackgroundblock instead, without the&, and its output goes to the block when it ends. Drag the pane's top edge to make it taller, or as short as one line. The blocks are added aszshwhen the file runs in zsh, elsesh. Turning History on starts the shells again, on a terminal, withTERM=xterm-256color, unless attyblock already did. - Front matter: the Front matter tab at the top of the rendered
view (or Edit › Front Matter, cmd/ctrl+shift+M) pulls the page down
to show a form for the file's front matter: its title, description
(or
summaryorabstract, whichever it has) and tags, themdsh:options (shell, on error, placeholders, stderr, step, terminal size) andenv:'s shared variables and sourced files. Keys the form has no field for are edited as YAML under Other keys. A field is written to the file as it changes, on leaving a text field or pressing enter, as one edit that Undo takes back; only the keys that changed are rewritten, so the rest keep their place and comments. Front matter mdsh refuses, or Other keys that aren't YAML, are said under the form and change nothing. Emptying every field takes the front matter out. The tab, Done or escape puts the page back. A file without front matter shows Add front matter instead. - Editing happens in the source view. The pencil (or
e) on a block opens it with the cursor on the block's code, and clicking prose opens it on that text. New blocks are typed there too. Inside{…}the editor completes attribute names and values (forfile=, the files beside the document and, asres://paths, those in its assets folder; forout=image:, the assets folder's), explains an attribute on hover and underlines mistakes. Vim key bindings are a setting; with them,:wsaves and:RunBlockruns the block at the cursor, as cmd/ctrl+enter does. With them on, an experimental setting makes the source pane a real Neovim (0.10 or newer, with your own config unless you turn it off). It works as the built-in editor does::wsaves,:RunBlockand:RunSectionrun what the cursor is in, as cmd/ctrl+enter and cmd/ctrl+shift+enter do, and the ▶ in the sign column runs a block or section. The pane attaches mdsh's language server (mdsh lsp, run asmdsh-gui --lsp): typing in a fence's{…}offers the same completions, there or through a completion plugin such as nvim-cmp,Kexplains the attribute under the cursor, and mistakes show as diagnostics. Spelling follows the setting, with Neovim'sspell. Headings, fences and output fold (zc,zo), as the file's folds say when it opens; the cursor's cell is marked and the panes scroll together; and the outline and a card's edit button move the cursor. The Insert menu puts blocks in at the cursor; the markdown bar is left out, as Vim has its own keys for that. It takes the app's colors and follows the Theme; a setting keeps the colorscheme from your config instead. - Checkboxes, textboxes and choices: task list items (
- [ ] label) in the rendered view check and uncheck in the file when clicked, and so do table cells that start with[ ]or- [ ](GitHub shows those as text). Checkboxes in a block's output, such asout=markdown's, work the same way until the block runs again and rewrites them. Atextboxblock (```textbox {#host lines=3 placeholder="Which host?"}) is a box to type in, at mostlineslines high (lines=fittakes any number and grows and shrinks with the text), showingplaceholderwhile empty; what is typed goes into the block's body. Drag the grip under a textbox, or focus it and press down and up, to make it taller until the window closes; a double click puts it back. Achoiceblock lists its options as task list items and is drawn as a dropdown, radio buttons or checkboxes (mode=dropdown,radioormulti). Withvar=name, blocks and conditions read the text or picks as$MDSH_VAR_name; a later input reusing a name is marked, with!in the outline, and ignored. All are edits like typing in the source view: Save writes them. - Include ranges: an include block (
<include file=… from=… to=…) shows its file's name and lines above its code, with an eye button that shows the whole file over the window, the included lines marked. A grip above and below the lines drags the range: the bottom one down to show the lines after, raisingto=, and the top one up to show the lines before, loweringfrom=. The lines appear as the grip moves, and the range is written when it is let go. At the file's edge the attribute comes out, so the include follows the file as it grows. With a grip focused, up and down move it a line. It is an edit like the others: Undo takes it back and Save writes it. - Dragging blocks and sections: a block card's grip (⋮⋮, at the left
of its head, shown on hover) drags the block, with its output, to a
spot between top-level cells; a line shows where it will go, the view
scrolls near its edges and Esc cancels. A top-level fence that doesn't
run, such as a Go example or a diagram, has a grip in the margin to its
left and drags the same way. In the outline each block and
heading has a grip too: a heading's drags its whole section (prose,
blocks, output and subsections), which goes only before a heading of
its level or higher, or to the end. A section that only partly holds
an
mdsh:ifsection doesn't move. Nor does a block, or a section, go below a block whosedepends=names it, or above one its owndepends=names: the line stops at the last spot short of that, turns gray, and the status line says why. The keys below keep to the same limit. Drags are edits like the keys below, with the same warnings and Undo. - Moving blocks: alt+↑ and alt+↓ (Edit › Move Block Up and Move
Block Down) move the selected block, or the textbox or choice being
used, past the cell above or below it; with shift they move it past
the block above or below, prose and all. Its output and its tape, when
the tape comes right after it, move with it; prose never does. Blocks
in a list or quote don't move. In the source view the keys move the
block the cursor is in, and anywhere else are the editor's own (move
or copy lines). A move keeps the block's output and status; if it
ran, the status line says it ran in the old order. When a move
changes something that depends on order, such as a condition that now
reads a block below it, a
$?that now reads another block, a block going in or out of anmdsh:ifsection, or which input sets a sharedvar=, a bar says so with an Undo button. Undo takes a move back like any other edit, in whichever view made it. Blocks without ids get them first, as saving gives them. - Undo in the rendered view: Edit › Undo (cmd/ctrl+Z) takes back the rendered view's last edit (checking a task, picking a choice, moving a block, or what was typed into a textbox since moving to it) and Redo (cmd/ctrl+shift+Z) does it again, up to 100 edits back. It is its own history: in the source view, and in a textbox while typing, undo is that editor's own. Once the file changes some other way, such as typing in the source view, a run writing output or Reload, the rendered view's earlier edits can't be undone.
- Links in the rendered view open when clicked: web links in the
browser, a markdown file in a new tab (or the tab it's already open
in), an image in the image viewer, and
#headinglinks scroll to the heading. Any other file is shown in Finder (or the file manager), not opened, so a link can't run a script or an app; Settings › Files lists the file types, such aspdf, that open in the system's app for them instead. Right-click a link to open or copy it. Links written in HTML, as<a href="...">, and the areas of an image map work the same. HTML in the markdown is drawn cleaned, without scripts, styles or handlers, and an<img>loads only from beside the document, as a markdown image does. - Source view (the
<>button or cmd/ctrl+\): the whole file in a markdown editor beside the rendered view. Typing re-renders after a pause, and the two scroll together; clicking a block lines the source up with it. Drag the line between them to share the width differently; a double click shares it evenly again. Blocks whose code didn't change keep their output. The play button in the gutter runs a block, or by a heading, its section. The rendered view can be turned off too (its button or cmd/ctrl+shift+\), to work in the source alone. - Markdown bar over the source view, and Insert in its right-click menu: heading, bold, italic, code, link, image, lists, quote, table, code block and an mdsh block. Tab moves between table cells.
- Outline (the sidebar button or cmd/ctrl+shift+O): headings and blocks with their state, to jump around in both panes. View › Show Code and Show Output hide those parts of the blocks.
- Code and output: code is highlighted in both views, with line numbers in the rendered view, for shell and the common languages, and ANSI colors in a block's output are drawn as colors.
- Folding: the arrow by a block's code or output folds it to its
first line, and the arrow by a heading folds its section, down to the
next heading of the same or a higher level. The outline's arrows fold
sections too.
collapse,collapse-outputand a<!-- mdsh:collapse -->line in a section say what starts folded; they take conditions, so{{$MDSH_VAR_name}}can fold or unfold a part as an input changes. Folding by hand writes the fold to the file, so it opens that way next time: a barecollapseorcollapse-outputon the block, or a<!-- mdsh:collapse -->line under the heading, and unfolding takes it out. Undo takes a fold back. Where the file folds by a condition, or while a block runs, a fold by hand lasts only while the tab is open. The source view folds headings and fences in its gutter, apart from the rendered view. View › Folding collapses all blocks or sections, expands all, and copies the folds from one view to the other. - Images: image, screenshot and recording output shows in the block, and so do images in the prose, from the document's folder. Click an output image to see it full size. Images from other sites are not loaded: opening a file never reaches the network, so a note with the image's alt text and host shows in its place, and so it is for an image outside the document's folder, or hidden in it. The note's Load image button loads the image and shows it, and remembers that the document may load that image, so it shows by itself the next time the document opens.
- Diagrams: a fenced
d2block shows as the diagram it draws, a fencedsvgblock as its picture, and a fencedcastblock (an asciinema recording) in the cast player, with a button to switch to the code and back. d2 diagrams are drawn by the built-in d2 library, with its dagre layout, in a light and a dark theme to match the window. When a diagram has a mistake, the code shows with d2's message under it. Pictures are shown as images, so an SVG's scripts don't run and it loads nothing. - Keys:
j/kselect a block,enterruns it,aruns from it,eedits it andccopies its code. - Copy: the copy button on a block's card (or
c) puts its code on the clipboard, as written in the file, without the fences or output. Other fenced code in the document shows the same button in its corner when the pointer is over it. A block's output has one too, in its corner, which copies the output as text, without its colors; it says Copied for a moment. - Run time: a block's output says, beside its copy button, how
long ago the run that made it started: "42 secs ago" under a minute,
then minutes, hours, days, weeks, months and years. It keeps counting
while the window is open, and its tooltip has the exact time and the
at=the file holds. Output saved without anat=shows none. - Earlier runs: a block with
history=Nshows the runs before its current output under it: a line says how many there are, and opens to each run's output under its time ("yesterday 16:21") and exit status, newest first. Each has a copy button and a trash, which deletes that run; Clear earlier runs, beside the output's trash, takes them all and keeps the current output. Undo puts them back, and saving deletes the image files of the runs they took. Create Report's Earlier runs switch puts them in the report. - Secrets: a block marked
secrethas its code and output blurred until you press the eye on its card; they blur again after a minute (Settings › Editing › Show secrets for) or when the window loses focus. A block whose code names a variable set withmdsh ctl set --secrethas its output blurred the same way. Copying a secret still works: on macOS the clipboard marks it concealed so clipboard managers skip it, and it comes off the clipboard after the same time unless something else was copied. - Screen readers and the keyboard: every button, pane, tab and
field has a name, and the toolbar's buttons say whether they are on.
Each block's card is a tab stop, named for the block, its language,
its attributes and its state (ran, failed with its exit status,
running, in the background, or waiting for an answer); focusing a
card selects it, so
enter,a,eandj/kwork from there. The outline's entries say what they are and their state, the fold buttons say whether they are open, and the window's tabs take the arrow keys, enter to show one and delete to close it, as Settings' tabs take the arrows. A question a block asks (confirm, depends=) puts the focus on Run and is read out with its reason; the status line, "running", errors and the end of a run are read out too. The grips that size the source view, the console and the History pane take the arrow keys, and in the outline ↑/↓ move between entries and ←/→ fold and unfold a section. Edit › Depends On… (d) edits the selected block'sdepends=as a list of the blocks above it to check, the keyboard's way to the dependency lines. The terminals read out what arrives (xterm's screen reader mode), and don't blink their cursor under reduce-motion. The Neovim source pane is a picture to a screen reader; the built-in editor is a text field. Keyboard focus shows a ring in every look, and with the system's reduce-motion setting the panes and folds don't slide and the views don't scroll smoothly. - Settings (mdsh › Settings… on macOS, Edit › Preferences… on
Linux) has tabs: General for the
view files open in (rendered, source or both; by default the view
the file was left in, rendered the first time) and the start folder; Look for the theme (System,
Light or Dark), the look (Plain, Teletype and the others pictured below, each in light and dark), the text size (80% to 200%; the outline widens with it), the interface and code fonts (any installed; the code font any of one width), line spacing,
an accent color, the History pane's colors (the window's, inverted,
or always dark) and the look's own textures, such as the Teletype
paper's sprocket strips, ruled lines and card shadows; Editing for autosave after
each run, Vim mode and spell checking of the prose in the
source view (on by default; not code, links or HTML); Shell for a shell for every file and the file
the History pane's shell reads; and Files for the templates folder
for New File… and the file types links open in their app. They are kept in
mdsh/gui.jsonin the user's config folder. Shell has one more, Give blocks your shell's aliases and functions, which adds anmdshfunction to~/.zshrc(or$ZDOTDIR/.zshrc), and to~/.bashrcwhen there is one, between marker comments, and unchecking it takes it out. The function runs the CLI with--source <(alias -L; typeset -f)(in bash,<(unset -f mdsh _mdsh; alias -p; declare -f)); the app itself isn't started from a shell, so it can't see them. The same block loadsmdsh's tab completion, in zsh oncecompinithas run. About shows the version and build, the Go version and platform, where the settings file,.zshrcand the folders from Settings are, whetherzsh,sh,mdshand the shell from Settings are on the app's PATH and their versions, and links to the cheat sheet, the changelog, docs, source and releases; Copy puts it on the clipboard for a bug report. The cheat sheet and the changelog are built into the app: their links, or Help › Cheat Sheet and Help › Changelog, open each in a read-only tab. The cheat sheet isdocs/cheatsheet.md, every attribute, key and flag on one page, and the changelog, with its screenshots, says what changed in the build you're running.mdsh-gui --versionprints the same version: the release's, or for ago installorgo buildbuild the module version or the commit it was built from.
If the file changes on disk, a banner offers to reload it. Reloading
keeps the shells, and the variables, functions and aliases blocks set
in them; a change to the front matter's shell:, env.share or
env.source waits for Restart Shells.
A tour
The start screen lists the runbooks in a folder, with the description from each one's front matter. Type to filter.

Collections
A .mdsh.yaml file in a folder of runbooks turns the folder into a
collection on the start screen: a header with an icon, title,
description and tags, in the folder's color, over a background image.
title: Deploys
description: Ship, roll back and check the prod stack.
icon: rocket.svg # an image in the folder, or one emoji: "🚀"
color: "#3b82f6" # #hex, rgb(), hsl() or a CSS color name
background: banner.png
tags: [ops, prod]
Every key is optional. Image paths are relative to the folder and must
stay inside it. A file's tags are those of the collections it is in,
from the listed folder down, plus the tags: in its own front matter.
The tag bar under the filter lists them all; click one, or type
#ops, to show only the files tagged ops. A header's tooltip lists
anything in .mdsh.yaml that was ignored, and a folder whose
.mdsh.yaml doesn't parse shows as a plain folder with a ⚠ that says
why.
You don't have to write the file by hand: the ⚙ beside a folder on the
start screen opens its settings, a form for the same keys, and saves
.mdsh.yaml for you. Clearing every field removes the file; keys and
comments the form doesn't know are kept. The gear shows only on folders
you can write to, and not on one whose .mdsh.yaml doesn't parse.
Run All streams each block's output in under it as it runs.

A background block runs on while the next ones do, with a dashed edge
until it ends. A confirm block asks in its card before it runs, and
so does a block that a block you run names in depends= and that hasn't
run yet.
Every block that Run all runs is drawn, even one that printing leaves
out because its show= is false or its <!-- mdsh:if --> section is
off. Such a block, and a tape hidden the same way, has a dashed edge and
a "hidden when printed" badge, and a section that holds one opens
unfolded even if the file folds it, so a file can't run code you never
saw.

A block's depends= is drawn as lines in the page margin, from the block
up to each block it names, painted faintly behind the cards: its first
dependency in purple, then pink, teal and orange, and any past four in
gray. Each line keeps a lane of its own, in the left margin when the
lanes fit there, else the right. Selecting a block lights its lines and
outlines the blocks they lead to in the same colors, in the rendered
view and in the outline. A block in a folded section is stood for by
the section's heading, and a heading standing for more than one gets a
ring for each, the first dependency's innermost; hover a line to
read what it joins, and double-click one to go to its far end. The
lines are edited where they are drawn. Each card has two anchors on its
edge: a ring at the top, where its lines leave, and a dot at the bottom,
where lines from the blocks that depend on it arrive. Drag the ring
onto a block above to depend on it, click the dot at a line's corner to
take that dependency out, or drag the dot to another block above to
depend on that one instead, or out past the lines, away from the cards,
to tear it off. Hold a dragged line over a folded section's heading
and the section opens, so the blocks in it can be dropped on; it folds
again when the line leaves it or the drag is called off, and stays open
for the tab (the file still folds it) when you drop on a block in it.
Each writes the block's depends=, so Undo
takes it back, and a cycle or a block that can't be depended on is
refused with mdsh's message. The button at the top of the margin hides
the lines and shows them again.
The outline lists the headings and blocks, with a mark for each block's state. The selected block, or the one the source pane's cursor is in, has a play button in the outline that runs it.
Each heading with a block under it has a play button beside it that
runs its section: the blocks under it, its subsections' included, down
to the next heading of the same or a higher level. They run as Run All
runs them, so confirm asks, skip, run= and run=once hold,
depends= runs what a block needs first even outside the section, and
on_error=stop ends the run. Click a heading, or pick it in the
outline, to select it: its play button shows in the outline, and enter
or s runs it. s on a selected block runs the section it is in.
While blocks run, the toolbar lists them, the run's current step (▶)
first and then those in the background (◐); click one to go to it.

The source view shows the file in a markdown editor, with the markdown bar over it, beside the rendered view. The two scroll together.

Image, screenshot and recording output shows in the block.

A tty block runs in a terminal in its card.

View › History opens a terminal along the bottom. Each command typed
there is added to the end of the file with its output, and each #
line as prose. A line such as # ```sh {#setup} starts a block
instead: the prompt becomes ```sh>, the lines typed after it
are kept rather than run, and a line of ``` adds the block to
the end of the file, as typed; ctrl+c drops it. Each file remembers whether its History pane was
open: a file opens with it closed until you open it there, so opening
a file doesn't start its shell unless you left History open in it.

If the file changes on disk, a banner offers to reload it.

File › Create Report… makes a PDF, HTML or markdown report, and shows
the mdsh command that makes the same one.

Tabs drag between windows, or out into a window of their own.

Settings opens in a tab, like the Changelog, and has tabs of its own for the view files open in and the start folder; the theme, the look and its options; autosave and Vim mode; the shell; the templates folder; and an About tab with the version, build, paths and tools.

Plain, since 1.0. Plain is the everyday look: the system's own face, white in the light theme and near black in the dark.

Teletype, since 1.3. Teletype sets everything in a typewriter face on fan-fold paper, or green phosphor when the theme is dark.






Blueprint, since 1.3. Blueprint draws in white lines on blue paper with a drafting grid, a deeper night blue when the theme is dark.




Bubble Gum, since 1.4. Bubble Gum is Hubba Bubba pink with bubbles across the page, puffy cards and bubble-lettered headings, or berry when the theme is dark.




Witchcraft, since 1.5. Witchcraft writes the document on a scroll of speckled kraft paper, framed in a double line with flourishes, against a sky of stars and crescent moons, with carved capitals for headings, or deep plum and gold when the theme is dark.



Coffee, since 1.6. Coffee writes the document on a sheet of old cream paper, splashed and ringed with coffee, lying on a wooden table beside a cup on a red saucer, with typewriter headings, or on dark-roast paper by a cup of black coffee when the theme is dark.



Green Tea, since 1.7. Green Tea writes the document on a sheet of washi laid on a tatami mat, with a bowl of matcha and a whisk by its corner and faint ink sketches of the tea things in its margins, or on the same sheet at evening, the room ink-dark and the matcha lit, when the theme is dark.



Install
Releases have a universal macOS app (.dmg and .zip), signed with a
Developer ID and notarized from 1.4 on, and a Linux AppImage; see
Desktop app. Both carry the mdsh
command line tool, built from the same commit: mdsh.app at
Contents/MacOS/mdsh, the AppImage at usr/bin/mdsh. Settings › Shell
puts it on PATH (a symlink in /usr/local/bin on macOS, a copy in
~/.local/bin from an AppImage); see
docs/design/cli-in-app.md.
Building
mdsh-gui is its own Go module, so the mdsh command doesn't pull in
Wails or need cgo. It needs Go 1.27 and cgo, plus:
- macOS: the Xcode command line tools.
- Linux: GTK 4 and WebKitGTK 6, for example
sudo apt-get install libgtk-4-dev libwebkitgtk-6.0-dev. - Windows: WebView2, which ships with current Windows.
cd cmd/mdsh-gui
go build .
On macOS, Wails, Go and the SDK ask for different minimum macOS versions, so the linker warns that object files were "built for newer 'macOS' version". The warnings are harmless; to build for one version and silence them:
MACOSX_DEPLOYMENT_TARGET=13.0 CGO_CFLAGS=-mmacosx-version-min=13.0 \
CGO_LDFLAGS=-mmacosx-version-min=13.0 go build .
The frontend is TypeScript in web/src (the root web package), bundled into
web/bundle and embedded in the binary, so go build needs
nothing more. After changing the TypeScript or the Go methods the
frontend calls, regenerate the bindings and the bundle (no npm needed):
go generate
The Neovim source pane is nvim --embed with the ext_linegrid UI:
nvim/ (the root nvim package) runs it and keeps its buffer in step
with the notebook, and
web/src/nvim.ts draws the grid on a canvas. Its tests run a real
Neovim, from $MDSH_TEST_NVIM or found as the app would, and skip
without one.
The code editor is CodeMirror 6 with Vim bindings, vendored as one
bundle in web/vendor/codemirror.js. go run ./internal/vendorjs
rebuilds it from the versions web/vendor/package-lock.json pins,
again without npm. To type-check the TypeScript:
npx --package typescript tsc -p ../../web
Packages
build/darwin/app.sh VERSION OUTDIR, on macOS, builds the universal
mdsh.app and puts it in a .dmg and a .zip. It signs the app ad
hoc, or with a Developer ID and notarizes it when MDSH_SIGN_IDENTITY
and the MDSH_NOTARY_* variables are set; see
docs/signing.md, which also says how the
release workflow gets them. The
.dmg window shows an arrow from mdsh to Applications; it is laid out
with dmgbuild by
build/darwin/dmg/settings.py, over a background drawn from
build/darwin/dmg/background.svg by build/darwin/dmg/render.sh.
app.sh also builds cmd/mdsh for both architectures into
Contents/MacOS/mdsh and signs it before the app.
build/linux/appimage.sh VERSION OUTDIR, on Linux, builds the
AppImage with wails3 generate appimage, which bundles GTK and WebKit's
helper processes, then adds mdsh and build/linux/AppRun, which runs
it for --cli or a link named mdsh, and packs the image again. The icon is build/appicon.png, drawn from
build/appicon.svg. .github/workflows/gui-packages.yml runs both;
the release workflow adds their files to the release.
Documentation
¶
Overview ¶
Command mdsh-gui opens markdown files in windows and runs their code blocks as you pick them, like mdsh -i does in a terminal.
mdsh-gui [flags] [file.md [args...] | folder] mdsh-gui --version mdsh-gui --serve=stdio [--source FILE] [file.md [args...] | folder]
--version prints the release version, or for a go install or go build build the module version or the commit it was built from.
With no file, the window lists the markdown files under the current folder to pick from, or under folder when one is given.
With --serve=stdio it opens no window and serves the notebook on stdin and stdout instead, as mdsh --serve=stdio does. It is experimental, and runs only once Settings › Shell turns it on.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
build
command
Command build bundles the frontend's TypeScript into web/bundle with esbuild, without npm, and makes what names the looks from their folders in web/looks (see package looks): web/src/looks.gen.ts, web/bundle/looks.css, the website's site/data/looks.toml and the GUI README's section on them.
|
Command build bundles the frontend's TypeScript into web/bundle with esbuild, without npm, and makes what names the looks from their folders in web/looks (see package looks): web/src/looks.gen.ts, web/bundle/looks.css, the website's site/data/looks.toml and the GUI README's section on them. |
|
newlook
command
Command newlook starts a new look for mdsh-gui: a folder in web/looks with a look.css that opens with the look's front matter (TOML between +++ lines in its first comment) and sets the plain look's colors under the new look's name, so it passes the tests from the start.
|
Command newlook starts a new look for mdsh-gui: a folder in web/looks with a look.css that opens with the look's front matter (TOML between +++ lines in its first comment) and sets the plain look's colors under the new look's name, so it passes the tests from the start. |
|
startuptime
command
Command startuptime launches mdsh-gui several times and reports how long it took to get to each point of starting up, from the marks it prints with MDSH_STARTUP_TRACE set (see ui/startup.go): the median and the fastest run of each.
|
Command startuptime launches mdsh-gui several times and reports how long it took to get to each point of starting up, from the marks it prints with MDSH_STARTUP_TRACE set (see ui/startup.go): the median and the fastest run of each. |
|
vendorjs
command
Command vendorjs rebuilds the JavaScript bundles mdsh-gui vendors, web/vendor/codemirror.js and web/vendor/xterm.js, without npm.
|
Command vendorjs rebuilds the JavaScript bundles mdsh-gui vendors, web/vendor/codemirror.js and web/vendor/xterm.js, without npm. |