TheDocumentation 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.
dir segment — which shows the current working directory — is arguably the most important piece of information in any shell prompt. Powerlevel10k goes to great lengths to keep it readable at any terminal width: it highlights the parts of the path that matter most and truncates the rest with the least possible loss of information.
How truncation works
When the full directory path does not fit on the prompt line, Powerlevel10k shortens it by replacing the leftmost segments with their shortest unique prefix. For example, if~/work is the only directory under ~ that starts with wo, it can be abbreviated to ~/wo. It cannot be shortened further to ~/w if another directory like ~/wireguard also starts with w.
This strategy — called truncate_to_unique — is set by the POWERLEVEL9K_SHORTEN_STRATEGY parameter:
Three segment colours
Every segment of the path is rendered in one of three distinct colours so you can immediately tell how much information has been retained:- Truncated segments are shown in a bleak, dim colour. They have been shortened and may not be unique if you have created new directories since the prompt was drawn.
- Important (anchor) segments are shown in a bright colour and are never truncated. These always include the first path component, the last component, and the roots of Git repositories. You always see them in full.
- Regular segments — those that are shown in full but could in principle be shortened — use an in-between colour.
~/.p10k.zsh are:
Configuration parameters
The key parameters that control directory display and truncation behaviour are:| Parameter | Default | Purpose |
|---|---|---|
POWERLEVEL9K_DIR_BACKGROUND | 4 | Background colour of the dir segment |
POWERLEVEL9K_DIR_FOREGROUND | 254 | Foreground colour of regular path segments |
POWERLEVEL9K_DIR_SHORTENED_FOREGROUND | 250 | Foreground colour of truncated (shortened) segments |
POWERLEVEL9K_DIR_ANCHOR_FOREGROUND | 255 | Foreground colour of anchor (important, never-shortened) segments |
POWERLEVEL9K_DIR_ANCHOR_BOLD | true | Whether anchor segments are rendered in bold |
POWERLEVEL9K_SHORTEN_STRATEGY | truncate_to_unique | Algorithm used to shorten path segments |
POWERLEVEL9K_SHORTEN_DIR_LENGTH | 1 | Number of trailing path segments that are always treated as anchors |
~/.p10k.zsh.
Tab-completing a truncated path
Rainbow style: visibility caveat
In Rainbow style, the current working directory is displayed as bright white text on a blue
background. The white is a fixed colour, but “blue” is whatever colour number 4 maps to in your
terminal’s colour palette. If your palette’s blue is very light (as it is in some default
configurations), white text on top of it can be difficult to read.There are several ways to fix this:
- Run
p10k configureand choose a different prompt style. - Change your terminal’s colour palette (e.g., switch to Tango Dark or Solarized Dark, or redefine just the blue entry).
- Adjust the directory colours directly in
~/.p10k.zshby changingPOWERLEVEL9K_DIR_BACKGROUND,POWERLEVEL9K_DIR_FOREGROUND,POWERLEVEL9K_DIR_SHORTENED_FOREGROUND,POWERLEVEL9K_DIR_ANCHOR_FOREGROUND, and/orPOWERLEVEL9K_DIR_ANCHOR_BOLDto values that produce better contrast in your terminal.