oh-my-posh/docs/docs/introduction.md
2020-10-05 19:44:46 +02:00

3.1 KiB

id title sidebar_label slug
introduction Introduction Introduction /

Oh my Posh is a custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable.

Oh my Posh 3 vs Oh my Posh 2

Oh my Posh 3 is the offspring of Oh my Posh, a prompt theme engine for PowerShell. Oh my Posh started out by being inspired from tools like oh my zsh when nothing was available specifically for PowerShell.

Over the years, I switched operating system/main shell quite a lot, even on Windows via the WSL. This made it so that my prompt wasn't portable enough, I wanted the same visual/functional experience regardless of the shell I was working in. Hello world Oh my Posh 3!

Concept

Traditionally, prompt tools work with custom scripts per theme (just like Oh my Posh did) or a lot of CLI configuration switches to define what it looks like. With Oh my Posh, I wanted to start from a single configuration file that could easily be shared anywhere, removing the need to really grasp what goes on underneath.

When you look at prompts like Agnoster or Paradox, you notice they usually consist of a few building blocks which contain one or more segments that display some sort of information. The configuration of Oh my Posh works exactly like that. Blocks are a combination of one or more segments.

The basic layout of the config file is as follows.

{
    "blocks": []
}

A block has properties that indicate its position and the segments it will render.

{
    "blocks": [
        {
            // positioning metadata (not shown)
            "segments": []
        }
    ]
}

A segment renders a single context like showing the current folder, user information or git status when relevant. It can be styled any way you want, resulting in visualizing the prompt you are looking for.

For your convenience, the existing themes from Oh my Posh have been added to version 3, so you can get started even without having to understand the theming. So, let's no longer waste time on theory, have a look at the installation guide to get started right away!

❤ Support ❤

Patreon Liberapay Ko-Fi