diff --git a/docs/docs/install-customize.md b/docs/docs/install-customize.md
index b660c7b6..0115071d 100644
--- a/docs/docs/install-customize.md
+++ b/docs/docs/install-customize.md
@@ -3,12 +3,12 @@ At this point, you're good to go. The `jandedobbeleer.omp.json` theme displays t
in your prompt, so 9/10 you'll be more than happy with it. However, if you want to explore additional
functionality, going through the additional steps below will help you get started.
-#### Change the theme
+### Change the theme
We downloaded all the themes and set `jandedobbeleer.omp.json` as the one to use.
However, there are [a lot more][themes] to be discovered and maybe there are some you like better.
-#### Override the theme settings
+## Override the theme settings
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 all
diff --git a/docs/docs/install-linux.mdx b/docs/docs/install-linux.mdx
index 48f58b3b..926f2698 100644
--- a/docs/docs/install-linux.mdx
+++ b/docs/docs/install-linux.mdx
@@ -11,7 +11,7 @@ import Customize from "./install-customize.md";
import CustomizeCmd from "./install-customize-cmd.mdx";
import InstallHomebrew from "./install-homebrew.mdx";
-### Setup your terminal
+## Setup your terminal
Oh My Posh uses ANSI color codes under the hood, these should work in every terminal,
but you may have to set the environment variable `$TERM` to `xterm-256color` for it to work.
@@ -20,7 +20,7 @@ but you may have to set the environment variable `$TERM` to `xterm-256color` for
-### Customize
+## Customize
diff --git a/docs/docs/install-macos.mdx b/docs/docs/install-macos.mdx
index b0bf049d..0ff9f8b7 100644
--- a/docs/docs/install-macos.mdx
+++ b/docs/docs/install-macos.mdx
@@ -11,7 +11,7 @@ import Customize from "./install-customize.md";
import CustomizeCmd from "./install-customize-cmd.mdx";
import InstallHomebrew from "./install-homebrew.mdx";
-### Setup your terminal
+## Setup your terminal
As the standard terminal has issues displaying the ANSI characters correctly, we advise using
[iTerm2][iterm2] or any other modern day MacOS terminal that supports ANSI characters.
@@ -20,7 +20,7 @@ As the standard terminal has issues displaying the ANSI characters correctly, we
-### Customize
+## Customize
diff --git a/docs/docs/install-pwsh.mdx b/docs/docs/install-pwsh.mdx
deleted file mode 100644
index 6250c0fc..00000000
--- a/docs/docs/install-pwsh.mdx
+++ /dev/null
@@ -1,93 +0,0 @@
----
-id: pwsh
-title: PowerShell
-sidebar_label: 🐚 PowerShell
----
-
-import Tabs from "@theme/Tabs";
-import TabItem from "@theme/TabItem";
-import Customize from "./install-customize.md";
-
-:::info
-This guide is for usage inside PowerShell only. If you plan to use Oh My Posh inside other shells as well,
-have a look at the platform-specific install instructions.
-:::
-
-## Installation
-
-```powershell
-Install-Module oh-my-posh -Scope CurrentUser
-```
-
-:::caution
-If you wish to install for **all users in a linux** environment, you will need to install from an **elevated PowerShell session**.
-You will also need to import the module one time from the elevated session in order to set the executable permissions correctly.
-
-```powershell
-sudo pwsh
-Install-Module oh-my-posh -Scope AllUsers
-Import-Module oh-my-posh
-```
-:::
-
-After installation, import Oh My Posh in your `$PROFILE`. Restart your shell and Oh My Posh will start downloading
-a compatible version of the executable (this is kept in sync on update).
-
-```powershell
-Import-Module oh-my-posh
-```
-
-## List all themes
-
-To display every available theme in the current directory, use the following
-cmdlet.
-
-```powershell
-Get-PoshThemes
-```
-
-The module installs all themes in the module folder. To find the actual files, you can use the following command:
-
-```powershell
-Get-PoshThemes -list
-```
-
-## Replace your existing prompt
-
-Edit `$PROFILE` in your preferred PowerShell version and add the following line. Autocompletion is available so it will loop
-through all available themes.
-
-```powershell
-Set-PoshPrompt -Theme jandedobbeleer
-```
-
-Once added, reload your profile for the changes to take effect.
-
-```powershell
-. $PROFILE
-```
-
-
-
-```powershell
-Export-PoshTheme -FilePath ~/.mytheme.omp.json -Format json
-```
-
-Once you're done editing, adjust your `$PROFILE` to use your newly created theme.
-
-```powershell
-Set-PoshPrompt -Theme ~/.mytheme.omp.json
-```
-
-## Update
-
-```powershell
-Update-Module oh-my-posh
-```
-
-🎉🎉🎉
-
-[scoop]: https://scoop.sh/
-[wt]: https://github.com/microsoft/terminal
-[powershell]: https://www.powershellgallery.com/packages/oh-my-posh
-[configuration]: /docs/config-overview
diff --git a/docs/docs/install-shells.mdx b/docs/docs/install-shells.mdx
index 13262be0..b3b164ac 100644
--- a/docs/docs/install-shells.mdx
+++ b/docs/docs/install-shells.mdx
@@ -26,6 +26,15 @@ oh-my-posh --print-shell
Edit `$PROFILE` in your preferred PowerShell version and add the following line.
+:::caution
+If you installed Oh My Posh using `Install-Module oh-my-posh`, you need to first import
+Oh My Posh in your `$PROFILE` before adding the line below:
+
+```powershell
+Import-Module oh-my-posh
+```
+:::
+
```powershell
oh-my-posh --init --shell pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression
```
diff --git a/docs/docs/install-windows.mdx b/docs/docs/install-windows.mdx
index 6bff5c14..b2542bd2 100644
--- a/docs/docs/install-windows.mdx
+++ b/docs/docs/install-windows.mdx
@@ -10,11 +10,11 @@ import Shells from "./install-shells.mdx";
import Customize from "./install-customize.md";
import CustomizeCmd from "./install-customize-cmd.mdx";
-### Setup your terminal
+## Setup your terminal
While Oh My Posh works on the standard terminal, we advise using the [Windows Terminal][wt].
-### Installation
+## Install
@@ -31,15 +32,6 @@ While Oh My Posh works on the standard terminal, we advise using the [Windows Te
winget install JanDeDobbeleer.OhMyPosh
```
-This installs a couple of things:
-
-- `oh-my-posh.exe` - Windows executable, added to your `$PATH`
-- `themes` - The latest Oh My Posh themes
-
-If you want to use a standard theme, you can find them in `~\AppData\Local\Programs\oh-my-posh\themes\`,
-referencing them as such
-will always keep them compatible with the binary when updating Oh My Posh.
-
@@ -47,14 +39,21 @@ will always keep them compatible with the binary when updating Oh My Posh.
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json
```
-This installs a couple of things:
+
+
-- `oh-my-posh.exe` - Windows executable, added to your `$PATH`
-- `themes` - The latest Oh My Posh themes
+:::warning
+The PowerShell module only installs the Oh My Posh execuatble inside PowerShell, to use Oh My posh outside of PowerShell,
+add the following folder to your `$PATH`:
-If you want to use a standard theme, you can find them in `~\scoop\apps\oh-my-posh\current\themes\`,
-referencing them as such
-will always keep them compatible with the binary when updating Oh My Posh.
+```powershell
+"$((Get-Item (Get-Module oh-my-posh).ModuleBase).Parent.FullName)"
+```
+:::
+
+```powershell
+Install-Module oh-my-posh -Scope CurrentUser
+```
@@ -67,78 +66,17 @@ The chocolatey package is managed by [Curtis Carter][cc]. In case of problems, p
choco install oh-my-posh
```
+
+
+
This installs a couple of things:
- `oh-my-posh.exe` - Windows executable, added to your `$PATH`
-- `themes` - The latest Oh My Posh themes
-
-If you want to use a standard theme, you can find them in `~\AppData\Local\Programs\oh-my-posh\themes\`,
-referencing them as such
-will always keep them compatible with the binary when updating Oh My Posh.
-
-
-
+- `themes` - The latest Oh My Posh [themes][themes]
For the `$PATH` to reload, a reboot is advised.
-### Usage
-
-#### Preview the themes
-
-
-
-
-```powershell
-Get-ChildItem -Path "~\AppData\Local\Programs\oh-my-posh\themes\*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
- $esc = [char]27
- Write-Host ""
- Write-Host "$esc[1m$($_.BaseName)$esc[0m"
- Write-Host ""
- oh-my-posh --config $($_.FullName) --pwd $PWD
- Write-Host ""
-}
-```
-
-
-
-
-```powershell
-Get-ChildItem -Path "$(scoop prefix oh-my-posh)\themes\*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
- $esc = [char]27
- Write-Host ""
- Write-Host "$esc[1m$($_.BaseName)$esc[0m"
- Write-Host ""
- oh-my-posh --config $($_.FullName) --pwd $PWD
- Write-Host ""
-}
-```
-
-
-
-
-```powershell
-Get-ChildItem -Path "~\AppData\Local\Programs\oh-my-posh\themes\*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
- $esc = [char]27
- Write-Host ""
- Write-Host "$esc[1m$($_.BaseName)$esc[0m"
- Write-Host ""
- oh-my-posh --config $($_.FullName) --pwd $PWD
- Write-Host ""
-}
-```
-
-
-
-
-#### Update
+## Update
@@ -162,6 +101,13 @@ winget upgrade JanDeDobbeleer.OhMyPosh
scoop update oh-my-posh
```
+
+
+
+```powershell
+Update-Module oh-my-posh
+```
+
@@ -172,7 +118,7 @@ choco upgrade oh-my-posh
-### Replace your existing prompt
+## Replace your existing prompt
@@ -196,6 +143,13 @@ You can find the themes scoop installs inside the `"$(scoop prefix oh-my-posh)\t
To use `jandedobbeleer.omp.json` for example, you can refer to it using `"$(scoop prefix oh-my-posh)\themes\jandedobbeleer.omp.json"`
when setting the prompt using the `--config` flag.
+
+
+
+You can find the themes PowerShell installs inside the `"$((Get-Module oh-my-posh).ModuleBase)\themes\"` folder.
+To use `jandedobbeleer.omp.json` for example, you can refer to it using `"$((Get-Module oh-my-posh).ModuleBase)\themes\jandedobbeleer.omp.json"`
+when setting the prompt using the `--config` flag.
+
@@ -215,6 +169,7 @@ Based on the installation method used, you can find this theme at the following
values={[
{ label: 'winget', value: 'winget', },
{ label: 'scoop', value: 'scoop', },
+ { label: 'powershell', value: 'powershell', },
{ label: 'chocolatey', value: 'chocolatey'},
]
}>
@@ -227,6 +182,11 @@ Based on the installation method used, you can find this theme at the following
`"$(scoop prefix oh-my-posh)\themes\jandedobbeleer.omp.json"`
+
+
+
+`"$((Get-Module oh-my-posh).ModuleBase)\themes\jandedobbeleer.omp.json"`
+
@@ -241,7 +201,7 @@ When using oh-my-posh inside the WSL, make sure to follow the [linux](linux) ins
-### Customize
+## Customize
@@ -262,3 +222,4 @@ Inside the WSL, replace `~` with the following path: `/mnt/c/Users/
-
-# Powershell doesn't default to UTF8 just yet, so we're forcing it as there are too many problems
-# that pop up when we don't
-if ($ExecutionContext.SessionState.LanguageMode -ne "ConstrainedLanguage") {
- [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
-}
-elseif ($env:POSH_CONSTRAINED_LANGUAGE -ne 1) {
- Write-Host "[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
-"
- $env:POSH_CONSTRAINED_LANGUAGE = 1
-}
+$env:POSH_THEMES_PATH = "$PSScriptRoot/themes"
+$env:PATH = "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase).Parent.FullName);$env:PATH"
function Get-PoshDownloadUrl {
param(
@@ -107,6 +91,8 @@ function Sync-PoshExecutable {
Sync-PoshExecutable
+# Legacy functions
+
function Set-PoshPrompt {
param(
[Parameter(Mandatory = $false)]
@@ -115,15 +101,15 @@ function Set-PoshPrompt {
)
$config = ""
- if (Test-Path "$PSScriptRoot/themes/$Theme.omp.json") {
- $path = "$PSScriptRoot/themes/$Theme.omp.json"
+ if (Test-Path "$($env:POSH_THEMES_PATH)/$Theme.omp.json") {
+ $path = "$($env:POSH_THEMES_PATH)/$Theme.omp.json"
$config = (Resolve-Path -Path $path).ProviderPath
}
elseif (Test-Path $Theme) {
$config = (Resolve-Path -Path $Theme).ProviderPath
}
else {
- $config = "$PSScriptRoot/themes/jandedobbeleer.omp.json"
+ $config = "$($env:POSH_THEMES_PATH)/jandedobbeleer.omp.json"
}
# Workaround for get-location/push-location/pop-location from within a module
@@ -135,138 +121,6 @@ function Set-PoshPrompt {
(& $poshCommand --init --shell=pwsh --config="$config") | Invoke-Expression
}
-<#
-.SYNOPSIS
- Returns an ansi formatted hyperlink
- if name not set, uri is used as the name of the hyperlink
-.EXAMPLE
- Get-Hyperlink
-#>
-function Get-Hyperlink {
- param(
- [Parameter(Mandatory, ValuefromPipeline = $True)]
- [string]$uri,
- [Parameter(ValuefromPipeline = $True)]
- [string]$name
- )
- $esc = [char]27
- if ("" -eq $name) {
- $name = $uri
- }
- if ($null -ne $env:WSL_DISTRO_NAME) {
- # wsl conversion if needed
- $uri = &wslpath -m $uri
- }
- return "$esc]8;;file://$uri$esc\$name$esc]8;;$esc\"
-}
-
-<#
-.SYNOPSIS
- Display a preview or a list of installed themes.
-.EXAMPLE
- Get-PoshThemes
-.Example
- Gest-PoshThemes -list
-#>
function Get-PoshThemes() {
- param(
- [switch]
- [Parameter(Mandatory = $false, HelpMessage = "List themes path")]
- $list
- )
- $consoleWidth = $Host.UI.RawUI.WindowSize.Width
- $logo = @'
- __ _____ _ ___ ___ ______ _ __
- / / | _ | | | \/ | | ___ \ | | \ \
- / / | | | | |__ | . . |_ _ | |_/ /__ ___| |__ \ \
-< < | | | | '_ \ | |\/| | | | | | __/ _ \/ __| '_ \ > >
- \ \ \ \_/ / | | | | | | | |_| | | | | (_) \__ \ | | | / /
- \_\ \___/|_| |_| \_| |_/\__, | \_| \___/|___/_| |_| /_/
- __/ |
- |___/
-'@
- Write-Host $logo
- $themes = Get-ChildItem -Path "$PSScriptRoot\themes\*" -Include '*.omp.json' | Sort-Object Name
- Write-Host ("-" * $consoleWidth)
- if ($list -eq $true) {
- $themes | Select-Object @{ Name = 'hyperlink'; Expression = { Get-Hyperlink -uri $_.fullname } } | Format-Table -HideTableHeaders
- }
- else {
- $poshCommand = Get-PoshCommand
- $themes | ForEach-Object -Process {
- Write-Host "Theme: $(Get-Hyperlink -uri $_.fullname -name $_.BaseName.Replace('.omp', ''))"
- Write-Host ""
- & $poshCommand -config $($_.FullName) -pwd $PWD
- Write-Host ""
- }
- }
- Write-Host ("-" * $consoleWidth)
- Write-Host ""
- Write-Host "Themes location: $(Get-Hyperlink -uri "$PSScriptRoot/themes")"
- Write-Host ""
- Write-Host "To change your theme, use the Set-PoshPrompt command. Example:"
- Write-Host " Set-PoshPrompt -Theme jandedobbeleer"
- Write-Host ""
+ Write-Host 'Get-PoshThemes is deprecated, please have a look at all the themes in the documentation: https://ohmyposh.dev/docs/themes'
}
-
-# Helper function to create argument completion results
-function New-CompletionResult {
- param(
- [Parameter(Mandatory)]
- [string]$CompletionText,
- [string]$ListItemText = $CompletionText,
- [System.Management.Automation.CompletionResultType]$CompletionResultType = [System.Management.Automation.CompletionResultType]::ParameterValue,
- [string]$ToolTip = $CompletionText
- )
-
- New-Object System.Management.Automation.CompletionResult $CompletionText, $ListItemText, $CompletionResultType, $ToolTip
-}
-
-function ThemeCompletion {
- param(
- $commandName,
- $parameterName,
- $wordToComplete,
- $commandAst,
- $fakeBoundParameter
- )
- $themes = Get-ChildItem -Path "$PSScriptRoot\themes\*" -Include '*.omp.json' | Sort-Object Name | Select-Object -Property @{
- label = 'BaseName'
- expression = { $_.BaseName.Replace('.omp', '') }
- }
- $themes |
- Where-Object { $_.BaseName.ToLower().StartsWith($wordToComplete.ToLower()); } |
- Select-Object -Unique -ExpandProperty BaseName |
- ForEach-Object { New-CompletionResult -CompletionText $_ }
-}
-
-Register-ArgumentCompleter `
- -CommandName Set-PoshPrompt `
- -ParameterName Theme `
- -ScriptBlock $function:ThemeCompletion
-
-
-# V2 compatibility functions
-# These should be removed at a certain point in time
-# but to facilitate ease of transition they are kept
-# as long as issues/feature requests keep popping up
-
-function Get-PoshInfoForV2Users {
- Write-Host @'
-
-Hi there!
-
-It seems you're using an oh-my-posh V2 cmdlet while running V3.
-To migrate your current setup to V3, have a look the documentation.
-
-https://ohmyposh.dev/docs/upgrading
-
-'@
-}
-
-Set-Alias -Name Set-Prompt -Value Get-PoshInfoForV2Users -Force
-Set-Alias -Name Get-ThemesLocation -Value Get-PoshInfoForV2Users -Force
-Set-Alias -Name Show-ThemeSymbols -Value Get-PoshInfoForV2Users -Force
-Set-Alias -Name Show-ThemeColors -Value Get-PoshInfoForV2Users -Force
-Set-Alias -Name Show-Colors -Value Get-PoshInfoForV2Users -Force
-Set-Alias -Name Write-ColorPreview -Value Get-PoshInfoForV2Users -Force
diff --git a/src/init/omp.ps1 b/src/init/omp.ps1
index 104a8578..2efd7063 100644
--- a/src/init/omp.ps1
+++ b/src/init/omp.ps1
@@ -2,13 +2,14 @@
# that pop up when we don't
if ($ExecutionContext.SessionState.LanguageMode -ne "ConstrainedLanguage") {
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
-} elseif ($env:POSH_CONSTRAINED_LANGUAGE -ne 1) {
+} else {
Write-Host "[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
"
}
+
$env:POWERLINE_COMMAND = "oh-my-posh"
$env:CONDA_PROMPT_MODIFIER = $false