magus v0.3.0 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 actually 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, 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 simply 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 (5118dbc9)
Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. See workspace.

Project

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

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. See targets.

Spell

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

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. See charms.

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. See the module reference.

Affected

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

CI

An ordinary magusfile-defined target you compose yourself with magus\needs - magus does not hardcode its stages. Magus.RunCI treats it specially only in that it strips the rw charm, it is the anchor magus affected ci keys off, and a selected scope with no project declaring it is a load error rather than a silent no-op. See targets.

Snapshot

A point-in-time view of live state - the pool's occupancy or a tick of exported metrics - as opposed to accumulated history. See daemon.

Insight

The reports magus derives over the graph and history (hotspots, affinity, ownership, trend). See insight.

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. See insight.

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. See insight.

Ownership

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

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. See insight.

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.