magus v0.4.3 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
2 min read

Shell setup

Two things worth doing once, after magus is installed and on your PATH: tab-completion, and the mgs shorthand. Both work under either name.

Shell completion

magus completion <shell> prints a completion script for bash, zsh, fish, or powershell (pwsh is accepted too). Every script registers both magus and the mgs shorthand, so you set this up once and get it under both names.

What it completes

  • Subcommands, and the subcommands under graph, config, server, self, and man.
  • Targets after run and affected: ls, build, test, lint, format, clean, generate, ci.
  • Project paths, live from the workspace. The script shells out to magus ls -o name, so it offers the projects this repo has rather than a baked-in list, and it stays correct as you add them.
  • Nouns after describe (spell, charm, target, project, workspace, module, mcp-tool) and lenses after insight (hotspots, affinity, ownership, trend, unreferenced, report).
  • Flags per subcommand, so magus affected --<TAB> offers --base, --plan, --bisect, and the rest rather than nothing.

Outside a workspace the project completions are empty. Nothing errors.

bash

Source it from your rc. The script is re-read from the binary on every new shell, so it cannot go stale after an upgrade:

echo 'source <(magus completion bash)' >> ~/.bashrc

zsh

Install it onto your $fpath as _magus:

mkdir -p ~/.zsh/completions
magus completion zsh > ~/.zsh/completions/_magus

Then in ~/.zshrc, before compinit runs:

fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit

Do not append the zsh script to ~/.zshrc. It ends by invoking its own completion function, which only means something inside a completion context; sourced from an rc it runs at shell startup and registers nothing.

Unlike the bash recipe this writes a snapshot, so regenerate it after a magus self update to pick up new subcommands and flags.

fish

Drop it in the completions directory, where fish loads it on demand:

magus completion fish > ~/.config/fish/completions/magus.fish

PowerShell

Append it to your profile:

magus completion powershell >> $PROFILE

Full reference: magus completion.

mgs shorthand

The de facto shorthand for magus is mgs: three left-hand keys, fast to type, and collision-free.

The install script creates it for you unless you pass --no-shorthand. To add it to an existing install:

magus self install-shorthand

That symlinks mgs next to the binary itself, so it is on your PATH if magus is. An existing mgs is left alone unless you pass --force, and --dir puts the link somewhere else. Full flag reference: magus self.

A symlink rather than a shell alias, because an alias only exists in interactive shells: mgs in a script, a Makefile, or a CI step would not resolve. The link also survives magus self update, which resolves symlinks before swapping the binary underneath.

completionshellbashzshfishpowershellmgsshorthandsetup
Last updated (7b7a69bb)
Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. Workspace in full.

Project

A directory magus recognizes as a unit of work (it has a magusfile); the unit of caching, scheduling, and dependency tracking. Project in full.

Target

A named operation (build, test, ...) you invoke with magus run <target>; it may compose a spell's tool-native operations and depend on other targets. Target in full.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). Op in full.

Spell

A language/runtime adapter (e.g. go, md) that maps generic targets onto a toolchain's real commands. Spell in full.

Charm

An execution modifier attached with : (lint:rw) that changes how a target runs, not which one; the built-in rw flips a check-only target to mutate in place, and ci always strips it. Charm in full.

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. Module in full.

Affected

The set of projects touched by a change; magus affected <target> runs a target only over them. Affected in full.

CI

An ordinary target you compose yourself with ctx.needs; magus does not hardcode its stages. It is the anchor magus affected ci keys off, and ci strips the rw charm. CI in full.

Snapshot

A point-in-time view of live state (the pool's occupancy or a tick of exported metrics), as opposed to accumulated history. Snapshot in full.

Insight

The reports magus derives over the graph and history (hotspots, affinity, ownership, trend, volatility, unreferenced). Insight in full.

Hotspot

An insight lens: edit frequency times complexity, the prime refactoring targets. The project view heat-colors the dependency graph by churn; --files ranks individual files. Hotspot in full.

Affinity

An insight lens: projects that change together (temporal coupling). A pair that co-changes without either declaring a dependency on the other is a candidate architectural smell. Affinity in full.

Ownership

An insight lens for author concentration: the primary author and their share, the distinct-author count (the bus factor), and abandonment. Ownership in full.

Trend

An insight lens: the recent half of the window against the earlier half. A positive delta is a rising hotspot; a negative one is cooling. Trend in full.

Tool

An action a model can call through its host: a name, a description, a typed input and a result. magus serves its tools over MCP, each a read of the workspace model or a run of the CLI it already has. Tool in full.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate. Run in full.

Conventions

Placeholders

Angle brackets mark a value you replace with your own; never type the brackets:

magus run <target>
magus completion <shell>    # e.g. bash, zsh, fish

<target>, <path>, <shell>, <name> and the like are stand-ins, not literal text.