Oh My Posh renders your prompt based on the definition of blocks (like Lego) which contain one or more segments. A really simple configuration could look like this.
With this configuration, a single powerline segment is rendered that shows the name of the folder you're currently in.
To set this configuration in combination with a Oh My Posh executable, use the
--config flag to
set a path to a JSON file containing the above code. The
--shell universal flag is used to print the prompt without
escape characters to see the prompt as it would be shown inside a prompt function for your shell.
The command below will not persist the configuration for your shell but print the prompt in your terminal. If you want to use your own configuration permanently, adjust the prompt configuration to use your custom theme.
If all goes according to plan, you should see the prompt being printed out on the line below. In case you see a lot of boxes with question marks, set up your terminal to use a supported font before continuing.
boolean- when true adds a space at the end of the prompt
boolean- when true adds support for OSC9;9; (notify terminal of current working directory)
boolean- when true sets the current location as the console title
string- the title to set in the console - defaults to
string- the template to use when
"console_title_style" = "template"
stringcolor - terminal background color, set to your terminal's background color when you notice black elements in Windows Terminal or the Visual Studio Code integrated terminal
"I Like The Way You Speak Words" - Gary Goodspeed
folder: show the current folder name
path: show the current path
template: show a custom template
You can create a more custom console title with the use of
"console_title_style" = "template".
When this is set, a
console_title_template is also expected, otherwise, the title will remain empty.
Under the hood, this uses go's text/template feature extended with sprig and
offers a few standard properties to work with.
boolean- is the current user root/admin or not
string- the current working directory
string- the current working folder
string- the current shell name
string- the current user name
string- the host name
string- Any environment variable where
VarNameis the environment variable name
boolean can be used for conditional display purposes, a
string can be displayed.
The following examples illustrate possible contents for
the current working directory is
/usr/home/omp and the shell is
Let's take a closer look at what defines a block.
arrayof one or more
Tells the engine what to do with the block. There are three options:
promptrenders one or more segments
rpromptrenders one or more segments aligned to the right of the cursor. Only one
rpromptblock is permitted. Supported on ZSH, Bash and Powershell.
Start the block on a new line. Defaults to
Tell the engine if the block should be left or right-aligned.
Move the block up or down x lines. For example,
vertical_offset: 1 moves the prompt down one line,
moves it up one line.
Moves the segment to the left or the right to have it exactly where you want it to be. Works like
but on a horizontal level where a negative number moves the block left and a positive number right.
Array of one or more segments.
A segment is a part of the prompt with a certain context. There are different types available out-of-the-box, if you're looking for what's included, feel free to skip this part and browse through the segments. Keep reading to understand how to configure a segment.
stringany of the included segments
string value referencing which segment logic it needs to run (see segments for possible values).
Oh Hi! You made it to a really interesting part, great! Style defines how a prompt is rendered. Looking at the most prompt themes out there, we identified 3 types. All of these require a different configuration and depending on the look you want to achieve you might need to understand/use them all.
What started it all for us. Makes use of a single symbol (
powerline_symbol) to separate the segments. It takes the
background color of the previous segment (or transparent if none) and the foreground of the current one (or transparent
if we're at the last segment). Expects segments to have a colored background, else there little use for this one.
Simple. Colored text on a transparent background. Make sure to set
foreground for maximum enjoyment.
Segments will be separated by empty spaces unless you specify
'' for the
postfix settings for the segment.
While Powerline works great with as single symbol, sometimes you want a segment to have a different start and end symbol.
Just like a diamond:
< my segment text >. The difference between this and plain is that the diamond symbols take the
segment background as their foreground color.
Text character to use when
true this swaps the foreground and background colors. Can be useful when the character you want does not exist
in the perfectly mirrored variant for example.
Text character to use at the start of the segment. Will take the background color of the segment as its foreground color.
Text character to use at the end of the segment. Will take the background color of the segment as its foreground color.
Color to use as the segment text foreground color. Also supports transparency using the
Array if string templates to define the foreground color for the given Segment based on the Segment's Template Properties. Under the hood this uses go's text/template feature extended with sprig and offers a few standard properties to work with. For supported Segments, look for the Template Properties section in the documentation.
The following sample is based on the AWS Segment.
The logic is as follows: when
background_templates contains an array, we will check every template line until there's
one that returns a non-empty string. So, when the contents of
.Profile contain the word
default, the first template
#FFA400 and that's the color that will be used. If it contains
jan, it returns
#f1184c. When none of the
templates returns a value, the foreground value
#ffffff is used.
Color to use as the segment text background color. Also supports transparency using the
Same as Foreground Templates but for the background color.
An array of Properties with a value. This is used inside of the segment logic to tweak what the output of the segment will be. Segments have the ability to define their own Properties, but there are some general ones being used by the engine which allow you to customize the output even more.
You can use these on any segment, the engine is responsible for adding them correctly.
The string content will be put in front of the segment's output text. Useful for symbols, text or other customizations.
If this is not set, it will be an empty space in
plain mode. If you want to remove the space before the segment,
specify this as
The string content will be put after the segment's output text. Useful for symbols, text or other customizations.
If this is not set, it will default to an empty space in
plain mode. If you want to remove the space after the segment,
specify this as
Sometimes you might want to have a segment only rendered in certain folders. If
include_folders is specified,
the segment will only be rendered when in one of those locations. If
exclude_folders is specified, the segment
will not be rendered when in one of the excluded locations.
The strings specified in these properties are evaluated as regular expressions. You
can use any valid regular expression construct, but the regular expression must match the entire directory
name. The following will match
/Users/posh/Projects/Foo but not
You can also combine these properties:
- Oh My Posh will accept both
\as path separators for a folder and will match regardless of which is used by the current operating system.
- Because the strings are evaluated as regular expressions, if you want to use a
\in a Windows directory name, you need to specify it as
- The character
~at the start of a specified folder will match the user's home directory.
- The comparison is case-insensitive on Windows and macOS, but case-sensitive on other operating systems.
This means that for user Bill, who has a user account
Bill on Windows and
bill on Linux,
~/Foo might match
C:\Users\Bill\foo on Windows but only
/home/bill/Foo on Linux.
Oh My Posh supports four different color types being:
Typical hex colors (for example
transparentkeyword which can be used to create either a transparent foreground override or transparent background color using the segment's foreground property.
inheritkeyword which can be used to inherit the previous active segment's foreground and/or background color.
16 ANSI color names.
These include 8 basic ANSI colors and
as well as 8 extended ANSI colors:
You have the ability to override the foreground and/or background color for text in any property that accepts it.
The syntax is custom but should be rather straight-forward:
<#ffffff,#000000>this is white with black background</> <#FF479C>but this is pink</>. Anything between the color start
<#FF479C> and end
</> will be colored accordingly.
For example, if you want
prefix to print a colored bracket that isn't the same as the segment's
foreground, you can
do so like this:
If you also wanted to change the background color in the previous command, you would do so like this:
To change only the background color, just omit the first color from the above string:
You can make use of the following syntax to decorate text:
boldas bold text
underlineas underlined text
italicas italic text
strikethroughas strikethrough text
This can be used in templates and icons/text inside your config.
The engine has the ability to render hyperlinks. Your terminal has to support it and the option has to be enabled at the segment level. Hyperlink generation is disabled by default.