2020-10-05 02:33:12 -07:00
---
2023-08-08 23:21:04 -07:00
id: general
2021-11-15 10:20:27 -08:00
title: General
sidebar_label: General
2020-10-05 02:33:12 -07:00
---
2022-06-03 13:35:11 -07:00
import Tabs from "@theme/Tabs";
2022-06-04 15:40:50 -07:00
import TabItem from "@theme/TabItem";
2022-06-03 13:35:11 -07:00
2021-06-05 10:27:33 -07:00
Oh My Posh renders your prompt based on the definition of _blocks_ (like Lego) which contain one or more _segments_.
2021-11-12 10:14:16 -08:00
A really simple configuration could look like this. The default format is `json`, but we also support `toml` and `yaml`.
There's a [schema][schema] available which is kept up-to-date and helps with autocomplete and validation of the configuration.
:::info
There are a few [themes][themes] available which are basically predefined configs. You can use these as they are, or as a
starting point to create your own configuration.
:::
2020-10-05 02:33:12 -07:00
2022-06-03 13:35:11 -07:00
<Tabs
defaultValue="json"
groupId="sample"
values={[
{ label: 'json', value: 'json', },
{ label: 'yaml', value: 'yaml', },
{ label: 'toml', value: 'toml', },
]
}>
<TabItem value="json">
2020-10-05 02:33:12 -07:00
```json
{
2021-11-12 10:14:16 -08:00
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
2020-10-05 02:33:12 -07:00
"final_space": true,
2022-11-08 22:56:23 -08:00
"version": 2,
2020-10-05 02:33:12 -07:00
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "path",
"style": "powerline",
2020-10-15 23:37:43 -07:00
"powerline_symbol": "\uE0B0",
2020-10-05 02:33:12 -07:00
"foreground": "#ffffff",
"background": "#61AFEF",
"properties": {
"style": "folder"
}
}
]
}
]
}
```
2022-06-03 13:35:11 -07:00
</TabItem>
<TabItem value="yaml">
```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
final_space: true
2022-11-08 22:56:23 -08:00
version: 2
2022-06-03 13:35:11 -07:00
blocks:
2022-06-04 15:40:50 -07:00
- type: prompt
alignment: left
segments:
- type: path
style: powerline
powerline_symbol: ""
foreground: "#ffffff"
background: "#61AFEF"
properties:
style: folder
2022-06-03 13:35:11 -07:00
```
</TabItem>
<TabItem value="toml">
```toml
"$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"
final_space = true
2022-11-08 22:56:23 -08:00
version = 2
2022-06-03 13:35:11 -07:00
[[blocks]]
type = "prompt"
alignment = "left"
[[blocks.segments]]
type = "path"
style = "powerline"
powerline_symbol = ""
foreground = "#ffffff"
background = "#61AFEF"
[blocks.segments.properties]
style = "folder"
```
</TabItem>
</Tabs>
2020-10-05 02:33:12 -07:00
With this configuration, a single powerline segment is rendered that shows the name of the folder you're currently in.
2021-06-05 10:27:33 -07:00
To set this configuration in combination with a Oh My Posh [executable][releases], use the `--config` flag to
2022-06-03 13:35:11 -07:00
set a path to a file containing the above code. The `--shell universal` flag is used to print the prompt without
2020-11-04 02:41:34 -08:00
escape characters to see the prompt as it would be shown inside a prompt function for your shell.
2021-09-01 04:45:33 -07:00
:::caution
2020-11-04 02:41:34 -08:00
The command below will not persist the configuration for your shell but print the prompt in your terminal.
2021-06-03 11:01:46 -07:00
If you want to use your own configuration permanently, adjust the prompt configuration to use your custom
2020-11-04 02:41:34 -08:00
theme.
:::
2020-10-05 02:33:12 -07:00
```bash
2022-03-25 11:03:37 -07:00
oh-my-posh print primary --config sample.json --shell uni
2020-10-05 02:33:12 -07:00
```
2020-11-13 04:24:08 -08:00
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
2021-11-12 10:14:16 -08:00
boxes with question marks, set up your terminal to use a [supported font][font] before continuing.
2020-10-05 02:33:12 -07:00
2022-03-09 09:14:11 -08:00
:::tip
The `--config` flag can accept either a local filepath or a remotely hosted config file.
For example, the following is a valid `--config` flag:
`--config 'https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/jandedobbeleer.omp.json'`
:::
2020-10-05 02:33:12 -07:00
## General Settings
2024-05-19 04:31:19 -07:00
| Name | Type | Description |
| ---------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `final_space` | `boolean` | when true adds a space at the end of the prompt |
| `pwd` | `string` | notify terminal of current working directory, values can be `osc99`, `osc7` or `osc51` depending on your terminal. Supports [templates][templates] |
| `terminal_background` | `string` | [color][colors] - 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 |
| `accent_color` | `string` | [color][colors] - accent color, used as a fallback when the `accent` [color][accent] is not supported |
| `var` | `map[string]any` | config variables to use in [templates][templates]. Can be any value |
| `shell_integration` | `boolean` | enable shell integration using FinalTerm's OSC sequences. Works in bash, cmd (Clink v1.14.25+), fish, powershell and zsh |
| `disable_cursor_positioning` | `boolean` | disable fetching the cursor position in bash and zsh in case of unwanted side-effects |
| `patch_pwsh_bleed` | `boolean` | patch a PowerShell bug where the background colors bleed into the next line at the end of the buffer (can be removed when [this][pwsh-bleed] is merged) |
| `disable_notice` | `boolean` | disable the upgrade notice |
2024-06-18 20:55:33 -07:00
| `auto_upgrade` | `boolean` | enable automatic upgrades for Oh My Posh (supports Windows/macOS only) |
2024-05-19 04:31:19 -07:00
| `iterm_features` | `[]string` | enable iTerm2 specific features:<ul><li>`prompt_mark`: add the `iterm2_prompt_mark` [function][iterm2-si] for supported shells</li><li>`current_dir`: expose the current directory for iTerm2</li><li>`remote_host`: expose the current remote and user for iTerm2</li></ul> |
2020-10-05 02:33:12 -07:00
2022-06-03 13:35:11 -07:00
### JSON Schema Validation
As mentioned above, Oh My Posh themes can utilize JSON Schema to validate their contents. Themes should include a link to
the [external schema document][schema] which prescribes the appropriate structure and contents for various elements. If
your code editor is configured to use JSON Schema, it will compare your custom theme to the external document, and issue
warnings for discrepancies.
For example, given the following code:
```json
...
"segments": [
{
"type": "an_invalid_entry",
"template": "{{ if gt .Code 0 }}\uf134{{ end }}",
}
]
...
```
Warnings will be raised for type, since `an_invalid_entry` is not in the list of acceptable values, as well as
2024-06-18 20:55:33 -07:00
for the entire segment item (enclosed in `{}`), since it lacks the required `style` key. Take advantage of these
2022-06-03 13:35:11 -07:00
warnings, and ignore them at your peril.
### Accepted Formats
Oh My Posh supports three file formats for themes: `json`, `yaml`, and `toml`.
2022-11-13 04:25:44 -08:00
Various converters exist to convert between these, although they aren't perfect and will require manual
2022-06-03 13:35:11 -07:00
adjustment. Notably, the schema implementation for json is as follows:
```json
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"
}
```
While for yaml:
```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
```
Converters won't catch this change, so you will need to adjust manually.
2021-02-15 23:36:37 -08:00
[releases]: https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest
2022-06-04 15:40:50 -07:00
[font]: /docs/installation/fonts
2021-11-12 10:14:16 -08:00
[schema]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/themes/schema.json
[themes]: https://github.com/JanDeDobbeleer/oh-my-posh/tree/main/themes
2022-05-22 00:11:16 -07:00
[colors]: /docs/configuration/colors
[accent]: /docs/configuration/colors#standard-colors
2023-02-19 11:21:33 -08:00
[templates]: /docs/configuration/templates#config-variables
2023-08-08 23:21:04 -07:00
[pwsh-bleed]: https://github.com/PowerShell/PowerShell/pull/19019
2024-05-19 04:31:19 -07:00
[iterm2-si]: https://iterm2.com/documentation-shell-integration.html