Closed Vixb1122 closed 3 years ago
Pretty sure that's an issue in how you invoke this in Powershell rather than an issue from OMP as I can't reproduce this anywhere. Did you do a manual configuration or are you using the module?
I installed oh-my-posh manually instead of module.
I installed oh-my-posh manually instead of module.
Can you share how you set it up? Probably something is off.
Completely follow the manual installation docs
mkdir C:\tools
Invoke-Webrequest https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/posh-windows-amd64.exe -OutFile C:\tools\oh-my-posh.exe
mkdir ~\.poshthemes
Invoke-Webrequest https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/themes.zip -OutFile ~\.poshthemes\themes.zip
Expand-Archive ~\.poshthemes\themes.zip -DestinationPath ~\.poshthemes -Force
Remove-Item ~\.poshthemes\themes.zip
[ScriptBlock]$Prompt = {
$lastCommandSuccess = $?
$realLASTEXITCODE = $global:LASTEXITCODE
$errorCode = 0
if ($lastCommandSuccess -eq $false) {
#native app exit code
if ($realLASTEXITCODE -ne 0) {
$errorCode = $realLASTEXITCODE
}
else {
$errorCode = 1
}
}
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
$startInfo.FileName = "C:\tools\oh-my-posh.exe"
$cleanPWD = $PWD.ProviderPath.TrimEnd("\")
$startInfo.Arguments = "-config=""$env:USERPROFILE\.poshthemes\jandedobbeleer.json"" -error=$errorCode -pwd=""$cleanPWD"""
$startInfo.Environment["TERM"] = "xterm-256color"
$startInfo.CreateNoWindow = $true
$startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
$startInfo.RedirectStandardOutput = $true
$startInfo.UseShellExecute = $false
if ($PWD.Provider.Name -eq 'FileSystem') {
$startInfo.WorkingDirectory = $PWD.ProviderPath
}
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $startInfo
$process.Start() | Out-Null
$standardOut = $process.StandardOutput.ReadToEnd()
$process.WaitForExit()
$standardOut
$global:LASTEXITCODE = $realLASTEXITCODE
#remove temp variables
Remove-Variable realLASTEXITCODE -Confirm:$false
Remove-Variable lastCommandSuccess -Confirm:$false
}
Set-Item -Path Function:prompt -Value $Prompt -Force
If the first execution after installation is OK, reopening the terminal will cause problems. @JanDeDobbeleer
@Vixb1122 do ma a favor, install the powershell module to see if that makes a difference. I can have a look this evening to see what's off between the manual installation guide and the module logic (not much, but there will be something).
Same error:
PS C:\Users\Vixb> Set-PoshPrompt -Theme ~\.poshthemes\sorin.json
Vixb@Vixb-PC ~ ❯❯❯ kajs
kajs: The term 'kajs' 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.
PS>
The reason is that $global:LASTEXITCODE can be empty. This fixes it:
[ScriptBlock]$Prompt = {
$lastCommandSuccess = $?
$realLASTEXITCODE = $global:LASTEXITCODE
$errorCode = 0
if ($lastCommandSuccess -eq $false) {
#native app exit code
- if ($realLASTEXITCODE -ne 0) {
+ if ($realLASTEXITCODE -is [int]) {
...
@WolfspiritM thx, that is useful.
@WolfspiritM thx for the quick fix!
@JanDeDobbeleer There is a new issue (or a legacy issue.): after every command execution error, an unfamiliar character(퀍) will appear. And The first execution after installation is OK,
❯❯ Vixb 23:24 tlaksj
tlaksj: The term 'tlaksj' 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.
❯❯ Vixb 퀍 23:25 kajs
kajs: The term 'kajs' 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.
❯❯ Vixb 퀍 23:30
That's probably the exit segment.
@JanDeDobbeleer Ok, You are right. \uD00D -> 퀍
You can override it with something else, when using a Nerd Font it should be something else.
Alright, some characters are missing from some Nerd Font. e.g.: FiraCode NF
That's possible. Which is why you can easily override these. As indicated, the font I use is Meslo. Most of the fonts I checked do work as it uses the NF cheat sheet.
This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.
Prerequisites
CONTRIBUTING
guideDescription
Unrecognized commands cause the theme to not work
Environment
Steps to Reproduce
Expected behavior: [What you expected to happen]
Actual behavior: [What actually happened]