-
Notifications
You must be signed in to change notification settings - Fork 947
Stylizing Your Prompt
You can configure the look and feel of your prompt easily with some built-in options.
By default, powerlevel9k
is a single-lined prompt. If you would like to have
the segments display on one line, and print the command prompt below it, simply
define POWERLEVEL9K_PROMPT_ON_NEWLINE
in your ~/.zshrc
:
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
If you want the right prompt to appear on the newline as well, simply
define POWERLEVEL9K_RPROMPT_ON_NEWLINE
as well in your ~/.zshrc
:
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
Here is an example of a double-lined prompt where the RPROMPT
is drawn on the newline:
If you want to split your segments up between two lines, make use of the newline
segment in segment list. For example:
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir newline vcs)
Will give you this left-side prompt:
You can customize the icons used to draw the multi-line prompt by setting the
following variables in your ~/.zshrc
:
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="↱"
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="↳ "
If you would like to add a newline before each prompt / print loop, like what's shown in the picture below:
Then just set the following in your ~/.zshrc
:
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
You can configure how many newlines
are inserted by setting the variable POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT
(defaults to 1
).
If you do not want a right prompt, you can completely disable it by setting:
POWERLEVEL9K_DISABLE_RPROMPT=true
If you prefer to use "light" colors, simply set POWERLEVEL9K_COLOR_SCHEME
to light
in your ~/.zshrc
, and you're all set!
POWERLEVEL9K_COLOR_SCHEME='light'
The 'light' color scheme works well for 'Solarized Light' users. Check it out:
Each icon in your prompt can be customized by specifying an appropriately named variable.
Simply prefix the name of the icon from the segment with 'POWERLEVEL9K', and export this as an environment variable set to the font codepoint (glyph code) you would like to use.
As an example, if you wanted to use a different glyph for the segment separators, you can easily do that with this:
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR=$'\uE0B1'
POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR=$'\uE0B3'
You can use this same approach to add or remove spacing in your prompt. For example, if you would like to remove the space after the "branch" icon in the vcs
segment, you can simply add a space after the codepoint for that icon:
POWERLEVEL9K_VCS_BRANCH_ICON=$'\uF126 '
If you are using git
and would like to customize the icon, please note that the icon is selected as follows:
Version | Icon to override |
---|---|
Github | VCS_GIT_GITHUB_ICON |
BitBucket | VCS_GIT_BITBUCKET_ICON |
GitLab | VCS_GIT_GITLAB_ICON |
All others | VCS_GIT_ICON |
We provide a function that will print every icon name in the theme. To get a full list of icons just type get_icon_names
in your terminal.
If you want to dump all of the icons you are using, shown in random colors, add the special segment icons_test
to your prompt:
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(icons_test)
This special prompt does not work on the right side, as it would be too long,
and ZSH hides it automatically. Please note that the output depends on
your POWERLEVEL9K_MODE
settings.
For each segment in your prompt, you can specify a foreground and background
color by setting them in your ~/.zshrc
. Use the segment names from the Available Prompt Segments section of the README.md
. For example, to change the appearance of the time
segment, you would use:
POWERLEVEL9K_TIME_FOREGROUND='red'
POWERLEVEL9K_TIME_BACKGROUND='blue'
Note that you can also use a colorcode value. Example:
POWERLEVEL9K_TIME_FOREGROUND='021' # Dark blue
For a full list of supported colors, run this little code in your terminal:
for code ({000..255}) print -P -- "$code: %F{$code}This is how your text would look like%f"
You can also reference this color chart:
Some segments have state. For example, if you become root, or modify a file in your version
control system, segments try to reflect this fact by changing the color.
For these segments you still can modify the color to your needs by setting a variable like
POWERLEVEL9K_<name-of-segment>_<state>_[BACKGROUND|FOREGROUND]
.
Segments with state are:
Segment | States |
---|---|
battery |
LOW , CHARGING , CHARGED , DISCONNECTED
|
context |
DEFAULT , ROOT , SUDO , REMOTE , REMOTE_SUDO
|
dir |
HOME , HOME_SUBFOLDER , DEFAULT , ETC , NOT_WRITABLE
|
dir_writable | FORBIDDEN |
disk_usage |
NORMAL , WARNING , CRITICAL
|
host |
LOCAL , REMOTE
|
load |
CRITICAL , WARNING , NORMAL
|
rspec_stats |
STATS_GOOD , STATS_AVG , STATS_BAD
|
status |
ERROR , OK (note: only, if verbose is not false) |
symfony2_tests |
TESTS_GOOD , TESTS_AVG , TESTS_BAD
|
user |
DEFAULT , SUDO , ROOT
|
vcs |
CLEAN , UNTRACKED , MODIFIED
|
vi_mode |
NORMAL , INSERT , VISUAL
|
Example:
# `vcs` color customization
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='blue'
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='black'
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='yellow'
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='black'
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='black'
# `vi_mode` color customization
POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND='teal'
Some terminal emulators allow you to customize the colors used by the terminal. P9k provides two commands that you can use to print out the colors & color-codes in use by your emulator to aid you in customization.
getColorCode background
getColorCode foreground
Most segment have a so called "visual identifier" which is an icon or string that serves as a "logo" for the segment. This identifier is displayed on the left side for left configured segments and on the right for right configured segments.
Let's assume you have configured the load
segment. This segment can have different states (CRITICAL
, WARNING
and NORMAL
). Now, we want to display the segment in black and white and colorize only the visual identifier.
# Segment in black and white
POWERLEVEL9K_LOAD_CRITICAL_BACKGROUND="black"
POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND="white"
POWERLEVEL9K_LOAD_WARNING_BACKGROUND="black"
POWERLEVEL9K_LOAD_WARNING_FOREGROUND="white"
POWERLEVEL9K_LOAD_NORMAL_BACKGROUND="black"
POWERLEVEL9K_LOAD_NORMAL_FOREGROUND="white"
# Colorize only the visual identifier
POWERLEVEL9K_LOAD_CRITICAL_VISUAL_IDENTIFIER_COLOR="red"
POWERLEVEL9K_LOAD_WARNING_VISUAL_IDENTIFIER_COLOR="yellow"
POWERLEVEL9K_LOAD_NORMAL_VISUAL_IDENTIFIER_COLOR="green"
It is possible to display two segments as one, by adding _joined
to your segment definition. The segments are always joined with their predecessor, so be sure that this is always visible. Otherwise you may get unwanted results. For example, if you want to join status
and background_jobs
in your right prompt together, set:
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs_joined)
This works with every segment, even with custom ones and with conditional ones.