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.
The default prompt
Section titled “The default prompt”Out of the box the prompt shows the directory, a ✓ or ! for the result of the command,
and how long it ran:
prompt.active = defaultprompt.profile.default.order = [dir, error_code, ok_code, duration]These segments are predefined and ready to use in your own order:
| Segment | Shows |
|---|---|
dir | current directory |
ok_code | ✓ when the command succeeded |
error_code | ! when the command failed |
duration | how long the command ran |
user | user name |
at | the text @ |
machine | host name |
emoji | 🎲 |
For example, to show user@machine before the directory:
prompt.profile.default.order = [user, at, machine, dir, error_code, ok_code, duration]Define a segment
Section titled “Define a segment”A segment has a name you choose and shows either a field or a text:
prompt.segment.dir.field = directoryprompt.segment.arrow.text = ❯Then add its name to the profile’s order.
Fields
Section titled “Fields”field | Value |
|---|---|
directory | current working directory |
user | user name |
machine | host name |
returnCode | exit code of the command |
duration | run time of the command |
isInput | true 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
Section titled “Format”format changes how a field’s value is displayed:
format | Result |
|---|---|
timespan | a duration as 1m 5s — use it with duration |
upper / lower | upper or lower case |
number | as a number |
json | as JSON |
Show a segment only sometimes
Section titled “Show a segment only sometimes”when hides a segment unless a condition holds:
prompt.segment.error_code.when = returnCode!=0A 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.
| Setting | Meaning |
|---|---|
foreground, background | a color name or a hex color, see below |
bold, italic, underline | true or false |
padding_left, padding_right | space inside the block |
margin_left, margin_right | space outside the block |
radius_left, radius_right | rounded corners |
title | tooltip 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.
Separator
Section titled “Separator”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 = " › "Example
Section titled “Example”The current directory, plus a red ! that only appears after a failed command:
prompt.active = mineprompt.profile.mine.order = [dir, failed]
prompt.segment.dir.field = directoryprompt.segment.dir.foreground = blackprompt.segment.dir.background = blueprompt.segment.dir.padding_left = 5prompt.segment.dir.padding_right = 5prompt.segment.dir.radius_right = 5
prompt.segment.failed.text = !prompt.segment.failed.foreground = whiteprompt.segment.failed.background = redprompt.segment.failed.margin_left = 5prompt.segment.failed.radius_left = 5prompt.segment.failed.radius_right = 5prompt.segment.failed.when = returnCode!=0Several profiles can live side by side; prompt.active picks the one in use.
All prompt settings are listed under Prompt in the settings reference.