Skip to main content

Spaceship prompt

Show your active Driverforge context — the selected organization and controller — right in your shell prompt, the way Spaceship shows the git branch or the Azure subscription:

~/drivers/acme-thermostat  on  main  󰢛 acme/living-room
Preview

The driverforge CLI is in preview. Commands and flags documented here may change before the stable release. Follow along or share feedback on our roadmap.

The section reads only the local context file (driverforge org current / driverforge device current — no network), renders asynchronously so it never blocks your prompt, and disappears entirely when no organization is selected.

Install

Save the snippet below as ~/.config/spaceship/driverforge.zsh, then in your ~/.zshrcafter Spaceship is initialised:

source ~/.config/spaceship/driverforge.zsh

and add driverforge to your prompt order:

SPACESHIP_PROMPT_ORDER=( dir git driverforge line_sep char )

The section

# Driverforge — active org/device section for the Spaceship prompt.

# Configuration (override any of these in ~/.zshrc before sourcing).
SPACESHIP_DRIVERFORGE_SHOW="${SPACESHIP_DRIVERFORGE_SHOW=true}"
SPACESHIP_DRIVERFORGE_SHOW_DEVICE="${SPACESHIP_DRIVERFORGE_SHOW_DEVICE=true}"
SPACESHIP_DRIVERFORGE_PREFIX="${SPACESHIP_DRIVERFORGE_PREFIX="using "}"
SPACESHIP_DRIVERFORGE_SUFFIX="${SPACESHIP_DRIVERFORGE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_DRIVERFORGE_SYMBOL=${SPACESHIP_DRIVERFORGE_SYMBOL=$'\U000F089B '} # nf-md-anvil (Nerd Font)
SPACESHIP_DRIVERFORGE_DEVICE_SEPARATOR="${SPACESHIP_DRIVERFORGE_DEVICE_SEPARATOR="/"}"
SPACESHIP_DRIVERFORGE_COLOR="${SPACESHIP_DRIVERFORGE_COLOR="#79C0FF"}"
SPACESHIP_DRIVERFORGE_COMMAND="${SPACESHIP_DRIVERFORGE_COMMAND=driverforge}"

# spaceship_driverforge renders the active driverforge org (and device, if
# selected), or nothing.
spaceship_driverforge() {
[[ $SPACESHIP_DRIVERFORGE_SHOW == false ]] && return

# Only render when the driverforge CLI is on PATH.
spaceship::exists "$SPACESHIP_DRIVERFORGE_COMMAND" || return

local org
org=$($SPACESHIP_DRIVERFORGE_COMMAND org current 2>/dev/null) || return
[[ -z $org ]] && return

local label="$org"
if [[ $SPACESHIP_DRIVERFORGE_SHOW_DEVICE != false ]]; then
local device
device=$($SPACESHIP_DRIVERFORGE_COMMAND device current 2>/dev/null)
[[ -n $device ]] && label="${org}${SPACESHIP_DRIVERFORGE_DEVICE_SEPARATOR}${device}"
fi

spaceship::section::v4 \
--color "$SPACESHIP_DRIVERFORGE_COLOR" \
--prefix "$SPACESHIP_DRIVERFORGE_PREFIX" \
--suffix "$SPACESHIP_DRIVERFORGE_SUFFIX" \
--symbol "$SPACESHIP_DRIVERFORGE_SYMBOL" \
"$label"
}

Options

Override any of these in ~/.zshrc before sourcing the file:

VariableDefaultEffect
SPACESHIP_DRIVERFORGE_SHOWtruefalse hides the section entirely
SPACESHIP_DRIVERFORGE_SHOW_DEVICEtruefalse shows only the org, never the controller
SPACESHIP_DRIVERFORGE_PREFIXusing Text before the section (matches Spaceship's Azure section)
SPACESHIP_DRIVERFORGE_SYMBOL󰢛 (anvil)Section symbol — see the font note below
SPACESHIP_DRIVERFORGE_DEVICE_SEPARATOR/Separator in org/device
SPACESHIP_DRIVERFORGE_COLOR#79C0FFSection colour (any zsh %F value: ANSI index or #rrggbb)
SPACESHIP_DRIVERFORGE_COMMANDdriverforgeBinary to query — point at a dev build if you have one

Font note

The default symbol is the Material Design anvil glyph (nf-md-anvil, U+F089B), which needs a full Nerd Font — a plain Powerline font (including plain Fira Code) only carries the Powerline glyphs and will show a missing-glyph box. Either install one:

brew install --cask font-fira-code-nerd-font   # then select "FiraCode Nerd Font" in your terminal

or override the symbol with an emoji, which renders anywhere:

SPACESHIP_DRIVERFORGE_SYMBOL="🛠️ "