oh-my-posh/website/docs/installation/customize.mdx

215 lines
5.8 KiB
Plaintext
Raw Normal View History

2022-03-09 02:39:31 -08:00
---
id: customize
title: Customize
sidebar_label: 💅🏼 Customize
---
2021-04-24 03:58:23 -07:00
import Tabs from "@theme/Tabs";
2022-03-18 05:38:20 -07:00
import TabItem from "@theme/TabItem"
2021-04-24 03:58:23 -07:00
2022-03-25 11:03:37 -07:00
The standard initialization sets Oh My Posh' [default theme][default-theme]. This configuration is downloaded
2022-08-07 02:30:01 -07:00
and kept up-to-date with Oh My Posh' version every time the shell starts.
To set a new config/theme you need
to change the `--config` option of the `oh-my-posh init <shell>` line in your `profile` or `.<shell>rc` script
(see [prompt][prompt]) and point it to the location of a predefined [theme][themes] or custom configuration on your file system.
<Tabs
defaultValue="windows"
groupId="shell"
values={[
{ label: 'windows', value: 'windows', },
{ label: 'homebrew', value: 'homebrew', },
]
}>
<TabItem value="windows">
When using the Windows installer (winget or Store install), you can make use of the `$POSH_THEMES` environment variable
that points to all [themes][themes] on your file system.
For example, to use the [jandedobbeleer][jandedobbeleer] theme, alter the init line like this (`powershell`):
```powershell
oh-my-posh init pwsh --config "$env:POSH_THEMES/jandedobbeleer.omp.json" | Invoke-Expression
```
</TabItem>
<TabItem value="homebrew">
When using homebrew, all themes are installed alongside Oh My Posh in `$(brew --prefix oh-my-posh)/themes`.
To use any of the themes, use the following syntax (`zsh`):
```bash
eval "$(oh-my-posh init zsh --config $(brew --prefix oh-my-posh)/themes/jandedobbeleer.omp.json)"
```
</TabItem>
</Tabs>
2022-03-18 05:15:57 -07:00
2022-03-18 05:38:20 -07:00
### Get inspiration
The best place to get started is by looking at the [themes][themes], as these are **predefined configurations** to use/alter.
To change to for example the [jandedobbeleer][jandedobbeleer] theme, alter the Oh My Posh `init` line to the following (assuming you
2022-03-18 05:15:57 -07:00
downloaded the configuration file to your user's home folder):
<Tabs
defaultValue="powershell"
groupId="shell"
values={[
{ label: 'powershell', value: 'powershell', },
{ label: 'cmd', value: 'cmd', },
{ label: 'zsh', value: 'zsh', },
{ label: 'bash', value: 'bash', },
{ label: 'fish', value: 'fish', },
{ label: 'nu', value: 'nu', },
]
}>
<TabItem value="powershell">
```powershell
2022-03-25 11:03:37 -07:00
oh-my-posh init pwsh --config ~/.jandedobbeleer.omp.json | Invoke-Expression
2022-03-18 05:15:57 -07:00
```
Once altered, reload your profile for the changes to take effect.
```powershell
. $PROFILE
```
:::info
When the above command gives an error, make sure to create the profile first and add the `oh-my-posh init` above.
```powershell
New-Item -Path $PROFILE -Type File -Force
```
:::
2022-03-18 05:15:57 -07:00
</TabItem>
<TabItem value="cmd">
```lua title="oh-my-posh.lua"
2022-03-25 11:03:37 -07:00
load(io.popen('oh-my-posh init cmd --config ~/.jandedobbeleer.omp.json'):read("*a"))()
2022-03-18 05:15:57 -07:00
```
Once altered, restart cmd for the changes to take effect.
</TabItem>
<TabItem value="zsh">
```bash
2022-03-25 11:03:37 -07:00
eval "$(oh-my-posh init zsh --config ~/.jandedobbeleer.omp.json)"
2022-03-18 05:15:57 -07:00
```
Once altered, reload your profile for the changes to take effect.
```bash
2022-03-18 05:38:20 -07:00
exec zsh
2022-03-18 05:15:57 -07:00
```
</TabItem>
<TabItem value="bash">
```bash
2022-03-25 11:03:37 -07:00
eval "$(oh-my-posh init bash --config ~/.jandedobbeleer.omp.json)"
2022-03-18 05:15:57 -07:00
```
Once altered, reload your profile for the changes to take effect.
```bash
exec bash
```
</TabItem>
<TabItem value="fish">
```bash
2022-03-25 11:03:37 -07:00
oh-my-posh init fish --config ~/.jandedobbeleer.omp.json | source
2022-03-18 05:15:57 -07:00
```
Once altered, reload your config for the changes to take effect.
```bash
. ~/.config/fish/config.fish
```
</TabItem>
<TabItem value="nu">
:::warning
Oh My Posh requires Nushell >= 0.60.0
:::
2022-03-18 05:15:57 -07:00
Run the following command:
2022-03-18 05:15:57 -07:00
```bash
oh-my-posh init nu --config ~/.jandedobbeleer.omp.json
```
it saves the initialization script to `~/.oh-my-posh.nu` by default.
Then edit the Nushell config file (`$nu.config-path`) and add the following line at the bottom:
```bash
source ~/.oh-my-posh.nu
2022-03-18 05:15:57 -07:00
```
If you want to save the initialization script elsewhere, you should run a command like:
```bash
oh-my-posh init nu --config ~/.jandedobbeleer.omp.json --print | save /mylocation/myscript.nu
```
and add the `source` line like:
```bash
source /mylocation/myscript.nu
```
Once altered, restart Nushell for the changes to take effect.
2022-03-18 05:15:57 -07:00
</TabItem>
</Tabs>
2022-03-18 05:38:20 -07:00
:::tip wsl
When using oh-my-posh in Windows and the WSL, know that you can **share your theme with the WSL** by pointing to a theme in your
2022-03-09 02:39:31 -08:00
Windows user's home folder.
Inside the WSL, you can find your Windows user's home folder here: `/mnt/c/Users/<WINDOWSUSERNAME>`.
:::
2022-03-18 05:38:20 -07:00
:::tip remote config
The `--config` flag can accept either a local filepath or a remotely hosted config file.
2021-04-24 03:58:23 -07:00
2022-03-18 05:38:20 -07:00
For example, the following is a valid `--config` flag:
2021-04-24 03:58:23 -07:00
```
2022-03-18 05:38:20 -07:00
--config 'https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/jandedobbeleer.omp.json'
2021-04-24 03:58:23 -07:00
```
2022-03-18 05:38:20 -07:00
:::
2021-04-24 03:58:23 -07:00
2022-03-18 05:38:20 -07:00
### Export the current theme
2021-04-24 03:58:23 -07:00
2022-03-18 05:38:20 -07:00
Maybe there's a theme you like, but you don't fancy the colors. Or, maybe there's a segment you
want to tweak/add, or replace some of the icons with a different one. Whatever the case, **read through
available options first**, by starting with the [configuration guide][configuration].
2021-04-24 03:58:23 -07:00
2022-06-03 13:35:11 -07:00
You can export the current theme (default, or set via `--config`) to the format you like (`json`, `yaml`, or `toml`)
2022-03-18 05:38:20 -07:00
which can be used to tweak and store as your own custom theme.
2021-04-24 03:58:23 -07:00
```bash
2022-03-21 12:48:42 -07:00
oh-my-posh config export --output ~/.mytheme.omp.json
2021-04-24 03:58:23 -07:00
```
2022-06-03 13:35:11 -07:00
### Read the docs
To fully understand how to customize a theme, read through the documentation in the configuration and segments sections.
The [configuration][configuration] section covers the basic building blocks and concepts of Oh My Posh themes, while the
segments section covers how to configure each available segment.
2022-03-09 02:39:31 -08:00
[themes]: themes.md
2022-07-01 12:41:47 -07:00
[configuration]: configuration/overview.mdx
2022-08-07 02:30:01 -07:00
[prompt]: prompt.mdx
2022-03-18 05:15:57 -07:00
[default-theme]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/themes/default.omp.json
[jandedobbeleer]: /docs/themes#jandedobbeleer
2022-07-01 12:41:47 -07:00
[json-schema]: https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json