Skip to content
Cogno v0.4.0

Prompt

Cogno draws its own prompt. You build it from segments: small colored blocks that show a value, such as the current directory, or a fixed text. A profile lists which segments appear and in which order.

The prompt needs shell integration, which is on by default. Changes apply to terminals you open afterwards.

Out of the box the prompt shows the directory, a ✓ or ! for the result of the command, and how long it ran:

prompt.active = default
prompt.profile.default.order = [dir, error_code, ok_code, duration]

These segments are predefined and ready to use in your own order:

SegmentShows
dircurrent directory
ok_code✓ when the command succeeded
error_code! when the command failed
durationhow long the command ran
useruser name
atthe text @
machinehost name
emoji🎲

For example, to show user@machine before the directory:

prompt.profile.default.order = [user, at, machine, dir, error_code, ok_code, duration]

A segment has a name you choose and shows either a field or a text:

prompt.segment.dir.field = directory
prompt.segment.arrow.text = ❯

Then add its name to the profile’s order.

fieldValue
directorycurrent working directory
useruser name
machinehost name
returnCodeexit code of the command
durationrun time of the command
isInputtrue on the line you are typing in, false on finished commands

returnCode and duration only exist once a command has finished. On the line you are typing in they are empty; set fallback to show something instead.

format changes how a field’s value is displayed:

formatResult
timespana duration as 1m 5s — use it with duration
upper / lowerupper or lower case
numberas a number
jsonas JSON

when hides a segment unless a condition holds:

prompt.segment.error_code.when = returnCode!=0

A condition is field==value or field!=value. These are the only two operators, and conditions cannot be combined. While the field has no value, the segment stays hidden — so a segment with when = returnCode!=0 never shows on the line you are typing in.

SettingMeaning
foreground, backgrounda color name or a hex color, see below
bold, italic, underlinetrue or false
padding_left, padding_rightspace inside the block
margin_left, margin_rightspace outside the block
radius_left, radius_rightrounded corners
titletooltip on hover

Colors. A name uses the matching color of your theme, so the prompt changes with it: black, red, green, yellow, blue, magenta, cyan, white, and their bright variants brightBlack, brightRed, … brightWhite. A hex color such as ff8800 is used as is.

default_separator puts a text between the segments of a profile. It only appears between segments that are actually shown:

prompt.profile.default.default_separator = " › "

The current directory, plus a red ! that only appears after a failed command:

prompt.active = mine
prompt.profile.mine.order = [dir, failed]
prompt.segment.dir.field = directory
prompt.segment.dir.foreground = black
prompt.segment.dir.background = blue
prompt.segment.dir.padding_left = 5
prompt.segment.dir.padding_right = 5
prompt.segment.dir.radius_right = 5
prompt.segment.failed.text = !
prompt.segment.failed.foreground = white
prompt.segment.failed.background = red
prompt.segment.failed.margin_left = 5
prompt.segment.failed.radius_left = 5
prompt.segment.failed.radius_right = 5
prompt.segment.failed.when = returnCode!=0

Several profiles can live side by side; prompt.active picks the one in use.

All prompt settings are listed under Prompt in the settings reference.