oh-my-posh/website/docs/faq.mdx

243 lines
8.8 KiB
Plaintext
Raw Normal View History

2021-04-29 12:14:28 -07:00
---
id: faq
title: FAQ
sidebar_label: 🤨 FAQ
---
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
Before validating anything, make sure you're on the [latest version][latest] of Oh My Posh and your terminal and shell are up-to-date.
2021-04-29 12:14:28 -07:00
### The prompt is slow (delay in showing the prompt between commands)
:::tip Windows
Make sure Windows Defender, or your AntiVirus, has an exclusion [configured][exclusion].
:::
2021-04-29 12:14:28 -07:00
<Tabs
defaultValue="powershell"
groupId="shell"
values={[
{ label: 'powershell', value: 'powershell', },
{ label: 'others', value: 'others', },
]
}>
<TabItem value="powershell">
You can use the `oh-my-posh debug` functionality to see where Oh My Posh spends its time.
2021-04-29 12:14:28 -07:00
In case there's no clear culprit (timings indicate everything's OK), chances are some modules are the culprit.
We bootstrap a few PowerShell modules to maximise compatibility, but sometimes these can introduce unwanted side-effects.
2021-04-29 12:14:28 -07:00
The modules we support are:
- posh-git
</TabItem>
<TabItem value="others">
You can use Oh My Posh's built-in debug functionality to identify slow segments.
2021-04-29 12:14:28 -07:00
```bash
oh-my-posh debug
2021-04-29 12:14:28 -07:00
```
2021-07-01 10:35:09 -07:00
Whenever there's a segment that spikes, see if there might be updates to the underlying functionality (usually shell commands).
2021-04-29 12:14:28 -07:00
</TabItem>
</Tabs>
If only your Git repo paths are slow, then try running [`git gc`][git-gc] to clean up and optimize the local repository.
2021-04-29 12:14:28 -07:00
If nothing seems to resolve the issue, feel free to [create an issue][new-issue].
### There are rectangles instead of icons in my prompt
The font you're using doesn't have the needed standard extended glyph set like [Nerd Font][nf] does.
Windows Terminal ships with Cascadia Code by default which has a powerline patched variant called Cascadia Code PL,
but also that one misses certain interesting icons. You can fall back to any theme with the `.minimal` indication,
or make use of a Nerd Font. Have a look at the [font][font] section for more context in case you're using all the right conditions.
### Text decoration styles like bold and dimmed don't work
The text decoration styles are based on your terminal emulator's capabilities.
A quick way to check if your terminal supports a specific style escape sequence is to take a look at the `terminfo` database, on Linux.
Refer [this page on ArchWiki][arch-terminfo].
If you are on Windows, use Windows Terminal. It closely copies the `xterm-256color` capabilities.
See the [PowerShell docs on terminal support][ps-ansi-docs] and [this GitHub comment][xterm-gh-comment].
2021-04-29 12:14:28 -07:00
### Windows Terminal: Unexpected space between segments/text
Windows Terminal has some issues with [rendering certain glyphs][wt-glyph]. These issues are on [their backlog][wt-glyphs].
A temporary workaround is to use an invisible character at the end (`\u2800`).
```json
{
2022-02-02 10:38:31 -08:00
"type": "executiontime",
/* other attributes here */
"properties": {
2021-04-29 12:14:28 -07:00
"always_enabled": true,
2022-02-02 10:38:31 -08:00
"template": "\ufbab\u2800" // invisible spacing character
}
2021-04-29 12:14:28 -07:00
}
```
2021-07-01 10:35:09 -07:00
### Jetbrains terminals: Icons do not render
2021-04-29 12:14:28 -07:00
They need to work on their terminal, somehow it only supports UTF-8 and not UTF-16.
2021-07-01 10:35:09 -07:00
[An issue][jb-icons] is available for a follow-up here.
2021-04-29 12:14:28 -07:00
### Strange colouring after exiting VIM or when using the PowerShell progress bootstrap
This bug is caused by Windows Terminal and/or VIM. There are two issues for this, one at [Windows Terminal][wt-vim] and
one at [VIM][vim-wt].
### Conda: environment name displayed in front of the prompt
Conda will automatically prepend the prompt with the name of the environment you're in.
To solely rely on Oh My Posh to set the prompt, you can configure the following setting to hide it.
Make sure to add this **before** initializing Oh My Posh.
```bash
conda config --set changeps1 False
```
### Python venv: Prompt changes on activating virtual environment
Virtual environments created with `venv` add the active environment's name to the prompt automatically.
To disable this behaviour, set `VIRTUAL_ENV_DISABLE_PROMPT` environment variable to `1` on your system. Example files:
2022-03-09 02:39:31 -08:00
Note: Tilde (~) in paths refers to your user's home directory.
<Tabs
defaultValue="powershell"
groupId="shell"
values={[
{ label: 'powershell', value: 'powershell', },
{ label: 'fish', value: 'fish', },
{ label: 'others', value: 'others', },
]
}>
<TabItem value="powershell">
```powershell
# Your PowerShell $PROFILE
$env:VIRTUAL_ENV_DISABLE_PROMPT=1
```
</TabItem>
<TabItem value="fish">
```fish
# ~/.config/fish/config.fish
set -x VIRTUAL_ENV_DISABLE_PROMPT 1
```
</TabItem>
<TabItem value="others">
```bash
# ~/.bashrc (bash) or ~/.zprofile or ~/.zshrc (zsh)
export VIRTUAL_ENV_DISABLE_PROMPT=1
```
</TabItem>
</Tabs>
### PowerShell: The term 'Set-Theme' is not recognized as the name of a cmdlet, function, script file, or operable program.
You need to migrate using the following [guide][migrating].
### PowerShell: Running in ConstrainedLanguage mode
You're here because you've seen the following message:
```powershell
[WARNING] ConstrainedLanguage mode detected, unable to set console to UTF-8.
When using PowerShell in ConstrainedLanguage mode, please set the
console mode manually to UTF-8. See here for more information:
https://ohmyposh.dev/docs/faq#powershell-running-in-constrainedlanguage-mode
```
When running PowerShell in ConstrainedLanguage mode, we can't set the console to UTF-8. This will cause the prompt to be rendered incorrectly.
There's a few [options][utf-8] to set the console to UTF-8 from an OS perspective on Windows, other systems shouldn't be impacted.
To remove the message after manual configuration, you can add the following to your `$PROFILE` before importing Oh My Posh:
```powershell
$env:POSH_CONSTRAINED_LANGUAGE = 1
```
2022-03-09 02:39:31 -08:00
### PowerShell: The term '.../oh-my-posh.exe' is not recognized as a name of a cmdlet...
2022-08-10 06:15:16 -07:00
For example:
2022-03-09 02:39:31 -08:00
```
&: The term 'C:/Users/TommiGr├╢nlund/.oh-my-posh/oh-my-posh.exe' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
```
The issue is that PowerShell on Windows doesn't yet default to UTF-8. Resolve the issue by setting the shell to UTF-8 in the scope of initializing Oh My Posh.
:::info Why it matters?
If the location contains non-ASCII characters, non-UTF-8 PowerShell may provide a wrong path to Oh My Posh, which can break the initialization.
The scenario for non-ASCII location:
- Your computer has a non-ASCII user name.
- Your [config file](./installation/customize.mdx) is under your `$HOME`.
:::
To do so, edit your `$PROFILE`, find the line that initializes Oh My Posh (as highlighted below), and change it to the following:
```powershell
$previousOutputEncoding = [Console]::OutputEncoding
[Console]::OutputEncoding = [Text.Encoding]::UTF8
try {
// highlight-start
oh-my-posh init pwsh --config ~/custom.omp.json | Invoke-Expression
// highlight-end
} finally {
[Console]::OutputEncoding = $previousOutputEncoding
}
```
Alternatively, let the whole shell become UTF-8. (Be aware: Unwanted side effects can happen.) Add the following line to the top of your `$PROFILE`:
2022-03-09 02:39:31 -08:00
```powershell
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
```
### Zsh: No command history (Ctrl+R does not work)
This issue occurs when you're using plain zsh in combination with Oh My Posh.
You fix this by can adding the right configuration to `~/.zshrc`.
```bash
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt appendhistory
```
### Fish: $(...) is not supported
You should update fish to v3.4.0 or higher. Fish supports `$(...)` and `"$(...)"` since v3.4.0, as described in its [changelog][fish-changelog].
[exclusion]: https://support.microsoft.com/en-us/windows/add-an-exclusion-to-windows-security-811816c0-4dfd-af4a-47e4-c301afe13b26
[arch-terminfo]: https://wiki.archlinux.org/title/Bash/Prompt_customization#Terminfo_escape_sequences
[ps-ansi-docs]: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_ansi_terminals?view=powershell-7.2
[xterm-gh-comment]: https://github.com/microsoft/terminal/issues/6045#issuecomment-631743728
[git-gc]: https://git-scm.com/docs/git-gc
2021-11-12 10:14:16 -08:00
[new-issue]: https://github.com/JanDeDobbeleer/oh-my-posh/issues/new/choose
2021-04-29 12:14:28 -07:00
[latest]: https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest
[wt-glyph]: https://github.com/microsoft/terminal/issues/3546
[wt-glyphs]: https://github.com/microsoft/terminal/issues?q=is%3Aissue+is%3Aopen+unicode+width
[nf]: https://www.nerdfonts.com/
2022-06-03 07:47:56 -07:00
[font]: /docs/installation/fonts
2021-04-29 12:14:28 -07:00
[jb-icons]: https://youtrack.jetbrains.com/issue/IDEA-248010
2022-04-25 22:50:59 -07:00
[migrating]: /docs/migrating
2021-04-29 12:14:28 -07:00
[wt-vim]: https://github.com/microsoft/terminal/issues/3794
[vim-wt]: https://github.com/vim/vim/issues/5092
[utf-8]: https://github.com/PowerShell/PowerShell/issues/7233#issuecomment-640243647
[fish-changelog]: https://fishshell.com/docs/current/relnotes.html#id1