When none of the 60+ built-in segments covers your use case, you can implement your own. Custom segments are full citizens of the Powerlevel10k prompt system: they support the same color, icon, and content configuration parameters as built-in segments, they can define states for conditional styling, and they participate in the same asynchronous rendering pipeline that keeps the prompt fast.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/romkatv/powerlevel10k/llms.txt
Use this file to discover all available pages before exploring further.
How Custom Segments Work
Powerlevel10k looks for a shell function namedprompt_<segmentname> every time it renders a prompt line that includes <segmentname> in POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. The function calls p10k segment to emit the segment’s content, icon, colors, and state. If the function returns without calling p10k segment, the segment is hidden entirely — no empty space is left in the prompt.
Creating a Custom Segment
Name your segment
Choose a name prefixed with
my_ to avoid conflicts with future built-in segments. For example: my_cpu_temp.Define the prompt function in ~/.p10k.zsh
Add a function named
prompt_my_<name>. The function is called during prompt rendering and must call p10k segment to produce output.Add the segment name to your prompt elements
Open
~/.p10k.zsh and add my_cpu_temp to the desired elements array:The p10k segment API
The p10k segment command is the only way for a prompt_* function to produce output. It can be called multiple times within a single function to emit multiple visual states, but only one call will “win” per render — the last non-hidden call takes effect.
| Flag | Argument | Description |
|---|---|---|
-s | STATE | Optional state name (e.g., HOT, COOL). Uppercased and appended to the parameter prefix for conditional styling. |
-b | BG | Background color: a number (0–255), a #RRGGBB truecolor string, or empty for transparent. Defaults to 0. |
-f | FG | Foreground color: a number, #RRGGBB, or empty for the terminal default. |
-i | ICON | Icon character or glyph to display before the text. Defaults to empty. |
-r | — | Icon is a symbolic reference (e.g., LOCK_ICON) to be resolved by Powerlevel10k’s icon table. |
+r | — | Icon is already resolved and should be printed literally (e.g., '⭐'). This is the default. |
-c | COND | Condition expression. If the value is empty after parameter expansion, the segment is hidden. Default is '1' (always shown). |
-t | TEXT | The segment’s main text content. Undergoes Zsh prompt expansion (%F{color}, %*, etc.). |
-e | — | Also expand -t TEXT via parameter expansion and process substitution (advanced use). |
+e | — | Do not expand -t TEXT via parameter expansion or process substitution. This is the default. |
-h | — | Print built-in help and exit. |
p10k help segment in an active Zsh session for the complete reference, including more examples.
State-Based Styling
When you pass-s STATE, Powerlevel10k appends the uppercased state to the POWERLEVEL9K_MY_<NAME>_ parameter prefix. This lets you assign different colors and icons per state in ~/.p10k.zsh without any extra logic in the function itself:
POWERLEVEL9K_<SEGMENT>_* parameters apply automatically, including _CONTENT_EXPANSION, _VISUAL_IDENTIFIER_EXPANSION, _SHOW_ON_COMMAND, and _PREFIX.
Instant Prompt Support
If your custom segment should display a cached value in the instant prompt, define a companioninstant_prompt_my_<name> function. Powerlevel10k calls both functions at the same time and replays the p10k segment calls from the instant prompt function when displaying the cached prompt.
instant_prompt_my_<name> is not defined, the segment is simply absent from the instant prompt display.
Hot Reload and Reload
By default,POWERLEVEL9K_DISABLE_HOT_RELOAD=true in configs created by the wizard. This means that if you modify POWERLEVEL9K_* parameters in an already-running interactive shell (rather than in ~/.p10k.zsh), the changes do not take effect immediately.
To apply changes without restarting Zsh:
p10k reload, set:
Complete Example — CPU Temperature Segment
The following is a complete, production-ready custom segment that reads CPU temperature from the Linux kernel’s thermal sysfs interface and displays it with state-based coloring:my_cpu_temp to POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS and run source ~/.p10k.zsh.