mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-17 08:24:04 -08:00
247 lines
6.8 KiB
Plaintext
247 lines
6.8 KiB
Plaintext
---
|
|
id: customize
|
|
title: Customize
|
|
sidebar_label: 💅🏼 Customize
|
|
---
|
|
|
|
import Tabs from "@theme/Tabs";
|
|
import TabItem from "@theme/TabItem"
|
|
|
|
The standard initialization sets Oh My Posh' default theme. This configuration is embedded
|
|
and thus kept up-to-date with Oh My Posh.
|
|
|
|
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.
|
|
|
|
There are two possible values the `--config` flag can handle:
|
|
|
|
- a path to a local configuration file
|
|
|
|
```powershell
|
|
oh-my-posh init pwsh --config 'C:/Users/Posh/jandedobbeleer.omp.json' | Invoke-Expression
|
|
```
|
|
|
|
- a URL pointing to a remote config
|
|
|
|
```powershell
|
|
oh-my-posh init pwsh --config 'https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/jandedobbeleer.omp.json' | Invoke-Expression
|
|
```
|
|
|
|
### Get inspiration
|
|
|
|
The Windows and homebrew installers also bundle the **predefined configurations** ([themes][themes]). You can use the
|
|
following way to reference them directly. This will keep them up-to-date and compatible with future updates.
|
|
|
|
<Tabs
|
|
defaultValue="windows"
|
|
groupId="shell"
|
|
values={[
|
|
{ label: 'windows', value: 'windows', },
|
|
{ label: 'homebrew', value: 'homebrew', },
|
|
]
|
|
}>
|
|
<TabItem value="windows">
|
|
|
|
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_PATH/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>
|
|
|
|
### Config syntax
|
|
|
|
The examples below use a local path to the [jandedobbeleer][jandedobbeleer] theme, adjust the `--config` value
|
|
to reflect your use-case.
|
|
|
|
<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
|
|
oh-my-posh init pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression
|
|
```
|
|
|
|
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
|
|
```
|
|
:::
|
|
|
|
</TabItem>
|
|
<TabItem value="cmd">
|
|
|
|
```lua title="oh-my-posh.lua"
|
|
load(io.popen('oh-my-posh init cmd --config C:/Users/Posh/jandedobbeleer.omp.json'):read("*a"))()
|
|
```
|
|
|
|
:::caution
|
|
Use the full path to the config file, not the relative path. You can make use of **forward slashes** to
|
|
avoid having to use double backslashes.
|
|
:::
|
|
|
|
Once altered, restart cmd for the changes to take effect.
|
|
|
|
</TabItem>
|
|
<TabItem value="zsh">
|
|
|
|
```bash
|
|
eval "$(oh-my-posh init zsh --config ~/jandedobbeleer.omp.json)"
|
|
```
|
|
|
|
Once altered, reload your profile for the changes to take effect.
|
|
|
|
```bash
|
|
exec zsh
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="bash">
|
|
|
|
```bash
|
|
eval "$(oh-my-posh init bash --config ~/jandedobbeleer.omp.json)"
|
|
```
|
|
|
|
Once altered, reload your profile for the changes to take effect.
|
|
|
|
```bash
|
|
exec bash
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="fish">
|
|
|
|
:::caution
|
|
Oh My Posh requires fish v3.4.0 or higher.
|
|
:::
|
|
|
|
```bash
|
|
oh-my-posh init fish --config ~/jandedobbeleer.omp.json | source
|
|
```
|
|
|
|
Once altered, reload your config for the changes to take effect.
|
|
|
|
```bash
|
|
. ~/.config/fish/config.fish
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="nu">
|
|
|
|
:::caution
|
|
Oh My Posh requires Nushell v0.70.0 or higher.
|
|
:::
|
|
|
|
Run the following command:
|
|
|
|
```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
|
|
```
|
|
|
|
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.
|
|
|
|
:::tip
|
|
For the time being, there is a [problem][homebrew-problem] with the initialization using Oh My Posh installed via Homebrew.
|
|
To resolve this, you can use the `--strict` flag which tells Oh My Posh to use the executable name and not the
|
|
full path in the initialization. For example:
|
|
|
|
```bash
|
|
oh-my-posh init nu --config ~/jandedobbeleer.omp.json --print --strict | save /mylocation/myscript.nu
|
|
```
|
|
|
|
This way for a new Oh My Posh version that does not update the initialization script, you don't have to recreate a new one.
|
|
:::
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
:::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
|
|
Windows user's home folder.
|
|
|
|
Inside the WSL, you can find your Windows user's home folder here: `/mnt/c/Users/<WINDOWSUSERNAME>`.
|
|
:::
|
|
|
|
### Adjust a theme
|
|
|
|
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].
|
|
|
|
You can export the current theme (default, or set via `--config`) to the format you like (`json`, `yaml`, or `toml`)
|
|
which can be used to tweak and store as your own custom theme.
|
|
|
|
|
|
```bash
|
|
oh-my-posh config export --output ~/.mytheme.omp.json
|
|
```
|
|
|
|
:::caution
|
|
Be careful not to adjust the theme files in their original location as they're updated together with Oh My Posh
|
|
which will remove your customizations. Always copy, or export them and save the new configuration outside of the
|
|
Oh My Posh internal themes folder.
|
|
:::
|
|
|
|
### 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.
|
|
|
|
[themes]: themes.md
|
|
[configuration]: configuration/overview.mdx
|
|
[prompt]: prompt.mdx
|
|
[jandedobbeleer]: /docs/themes#jandedobbeleer
|
|
[json-schema]: https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
|
|
[homebrew-problem]: https://github.com/JanDeDobbeleer/oh-my-posh/discussions/2644
|