Closed lucasjinreal closed 2 years ago
@jinfagang as the issue guide states, I need the output of oh-my-posh debug
in this use-case. You can copy-paste the output here.
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 debug: User
Administrator
2022/09/15 22:47:52 User duration: 0s, args:
2022/09/15 22:47:52 debug: Host
TX-R90VB4H0
2022/09/15 22:47:52 Host duration: 0s, args:
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 519.2µs, args:
2022/09/15 22:47:52 Flags duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 debug: Getenv
2022/09/15 22:47:52 Getenv duration: 0s, args: SSH_CONNECTION
2022/09/15 22:47:52 debug: Getenv
2022/09/15 22:47:52 Getenv duration: 0s, args: SSH_CLIENT
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 Shell duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 Shell duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 debug: CommandPath
C:\Program Files\Git\cmd\git.exe
2022/09/15 22:47:52 CommandPath duration: 3.8281ms, args: git.exe
2022/09/15 22:47:52 HasCommand duration: 3.8281ms, args: git.exe
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 error: HasParentFilePath
CreateFile C:\.git: The system cannot find the file specified.
2022/09/15 22:47:52 HasParentFilePath duration: 0s, args: .git
2022/09/15 22:47:52 Flags duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 Shell duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 ExecutionTime duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 Shell duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 Root duration: 54.3µs, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 Shell duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 Shell duration: 0s, args:
2022/09/15 22:47:52 Flags duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 Flags duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 PathSeparator duration: 0s, args:
2022/09/15 22:47:52 PathSeparator duration: 0s, args:
2022/09/15 22:47:52 PathSeparator duration: 0s, args:
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 IsWsl duration: 0s, args:
2022/09/15 22:47:52 StackCount duration: 0s, args:
2022/09/15 22:47:52 DirIsWritable duration: 506.4µs, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 Shell duration: 0s, args:
2022/09/15 22:47:52 debug: Pwd
C:\Users\Administrator
2022/09/15 22:47:52 Pwd duration: 0s, args:
2022/09/15 22:47:52 debug: Home
C:\Users\Administrator
2022/09/15 22:47:52 GOOS duration: 0s, args:
2022/09/15 22:47:52 ErrorCode duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 Shell duration: 0s, args:
2022/09/15 22:47:52 TemplateCache duration: 0s, args:
2022/09/15 22:47:52 debug: Getenv
C:\Users\Administrator\AppData\Local
2022/09/15 22:47:52 Getenv duration: 0s, args: LOCALAPPDATA
2022/09/15 22:47:52 CachePath duration: 529.9µs, args:
2022/09/15 22:47:52 Flags duration: 0s, args:
@jinfagang can I get the full output? This seems like only half of it.
does there a file saved? the terminal screen has a very long print
@jinfagang you can pipe this to clip -> oh-my-posh debug | clip
I'm having the same problem
I use oh my posh on wsl
@gf9276 same question as above, I need the logs otherwise this will get closed in a few days automatically.
don't matically, close it. I am too lazy to touch a log... but problem still un solved.
@JanDeDobbeleer Thank you for your reply. The problem has been solved, most of the themes have not been added to the python segment, so the virtual environment of conda cannot be displayed, and I have made a little modification to its code.
@gf9276 Can u verifed which theme have python segment? themes suggested by @JanDeDobbeleer certainly don't have .....
@jinfagang I looked at the code for all the themes, 'night-owl' is the most comprehensive.
OK, I given it up.. don't know what i missed here, but still none of theme shows conda env name.
whats your promot looks like?
Open wsl in windows terminal,like this. Seems like we're not using the same theme. Are you using 'night-owl.omp.json'?
@jinfagang you're not using a theme. The path you shared in init
is incorrect.
@jinfagang You can write a theme yourself, plus the segments you need. I found that arrows will have some bugs in vscode, like this: So I rewrote a theme myself based on '1_shell', and I am using this.
@JanDeDobbeleer I am confused here:
I set it night-owl
.
why did say not same theme? @gf9276 can u try in Powershell? I am not using wsl.
@jinfagang do you have the $env:POSH_THEME_PATH
variable? It's either that or the path isn't accessible for oh-my-posh.
@jinfagang i think you loss .omp......
@jinfagang night-owl.omp.json, not night-owl.json
@gf9276 thanks for reminding this. Still can not see conda env names.
@jinfagang the default display_mode
for python is environment
which is also true for night-owl. If you want to understand what oh-my-posh sees in your env, and why it displays what it does, make use of oh-my-posh debug
and provide the full content of the logs here. Only then can I guide you to a solution. Python is the worst toolchain out there in terms of support so there are a ton of edge cases and bad practices which can influence the output.
@jinfagang , When not using oh my posh, will power shell show the conda environment? Maybe you should use the anaconda prompt for conda operations. But I don't have conda installed on win, so I can't verify .
@gf9276 nop. without ph my posh also can not show
@jinfagang It seems that it is normal that the conda environment is not displayed on the power shell,you should use anaconda prompt.
@gf9276 @jinfagang oh-my-posh can show the correct information, provided it's also available in the environment. Which is why I've been asking for the logs for a while now. So, if you care about finding out why and get to the bottom of this, you'll need to do a quick copy pasting instead of starting a mega thread into oblivion.
@JanDeDobbeleer Yes, you are right.
@jinfagang You had better provide logs, or you can try the following command.
Step 1: Find and open Anaconda Prompt in the Anaconda directory of the start menu, input the command:
conda init --all
Step 2: Reopen PowerShell, if there is a red letter error and you still do not enter the conda environment, then open PowerShell as an administrator and enter:
Set-ExecutionPolicy RemoteSigned
Then select Y, reopen PowerShell, you can see the word (base) appears, enter conda activate XXX to enter the corresponding virtual environment.If this still doesn't work, you might as well provide a full logs.
conda init --all
solved my problem. Thanks
@jinfagang the default
display_mode
for python isenvironment
which is also true for night-owl. If you want to understand what oh-my-posh sees in your env, and why it displays what it does, make use ofoh-my-posh debug
and provide the full content of the logs here. Only then can I guide you to a solution. Python is the worst toolchain out there in terms of support so there are a ton of edge cases and bad practices which can influence the output.
Hi,I also meet this problem in powershell,and below is the output of oh-my-posh debug | clip
:
output.txt
and my profile.ps1
is shown below:
# posh-git (`Install-Module Posh-Git -Scope CurrentUser`)
# Import-Module Posh-Git
# Icons
Import-Module -Name Terminal-Icons
# Oh-My-Posh (`winget install oh-my-posh`)
# $env:POSH_GIT_ENABLED = $true
# oh-my-posh init pwsh --config $env:POSH_THEMES_PATH/kushal.omp.json | Invoke-Expression
oh-my-posh init pwsh --config $env:POSH_THEMES_PATH/powerlevel10k_rainbow.omp.json | Invoke-Expression
Set-PSReadLineOption -PredictionSource History # 设置预测文本来源为历史记录
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete # 设置 Tab 键补全
Set-PSReadLineKeyHandler -Chord "Ctrl+RightArrow" -Function ForwardWord # 设置 ctrl + 向右键逐字补全
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 设置向下键为前向搜索历史纪录
# 3. 查看目录 ls & ll
function ListDirectory {
(Get-ChildItem).Name
Write-Host("")
}
Set-Alias -Name ls -Value ListDirectory
Set-Alias -Name ll -Value Get-ChildItem
# winget
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
$Local:word = $wordToComplete.Replace('"', '""')
$Local:ast = $commandAst.ToString().Replace('"', '""')
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
#Invoke-Expression (&starship init powershell)
@Hezhexi2002 it would be good to update first. You're still on an older version.
@Hezhexi2002 it would be good to update first. You're still on an older version.
The problem still exists after I upgrade it:
@VVingerfly you're in the HOME
folder though. The env name by default doesn't show in there (see home_enabled
).
@VVingerfly you're in the
HOME
folder though. The env name by default doesn't show in there (seehome_enabled
).
But the env name still not shown when I change to another folder instead of HOME
:
@Hezhexi2002 I see, and according to your previous debug log, I see you're using powerlevel10k
which has fetching the virtual env disabled.
@Hezhexi2002 I see, and according to your previous debug log, I see you're using
powerlevel10k
which has fetching the virtual env disabled.
so how could I change it to True
?
@Hezhexi2002 by reading the documentation on how to adjust.
@Hezhexi2002 by reading the documentation on how to adjust.
ok,as you can see I have set the fetch_virtual_env
to true
but still the same:
@Hezhexi2002 yes, but that's also in your HOME folder which is disabled by default as well.
@Hezhexi2002 yes, but that's also in your HOME folder which is disabled by default as well.
but it didn't work even when I change the folder again:
@Hezhexi2002 we're going in circles here which is a bit annoying tbh, can you share the output of oh-my-posh debug
in that folder?
@Hezhexi2002 we're going in circles here which is a bit annoying tbh, can you share the output of
oh-my-posh debug
in that folder?
Sorry to anwser you so lately because I'm a little busy with school starting these days,here is the output of oh-my-posh debug | clip
in that folder:
output.txt
Sorry again for bothering you for so long, I hope you can understand
@Hezhexi2002 so, it seems only CONDA_DEFAULT_ENV
has a value which is base
. Your python segment's template
however doesn't use the .Venv
property so it will never show that value and on top of that your display_mode
is files which doesn't show unless there are python files inside the folder you're in (which isn't the case). I suggest to change that to context
and also include {{ .Venv }}
in your template. Reading the documentation should also explain all of those things in detail.
@JanDeDobbeleer I hope you're doing well. I wanted to get back to you regarding the changes I made to my Oh My Posh configuration based on your advice like below: They did help display the Conda virtual environment name, but I noticed a new quirk.
Now, the virtual environment name and Python version show up, but only when I navigate from my home directory to another directory within PowerShell. When I first launch PowerShell from my home directory, they don't appear until I change directories just like below: Is there a way to make them show up right from the start when I launch PowerShell, regardless of the directory I'm in? If you have any tips or ideas on how to achieve this, I'd really appreciate it.
Thanks again for your help and insights. Looking forward to your thoughts.
Best regards, hezhexi2002
@Hezhexi2002 yes, but that's also in your HOME folder which is disabled by default as well.
@Hezhexi2002 as stated above, to have this visible in the home folder, you need to also add "home_enabled": true
to the segment's properties
.
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.
Code of Conduct
What would you like to see changed/added?
Something new and amazing!
Sorry for bother again, I have tried all these 3 themes, none of themshows conda env name:
![Uploading image.png…]()
what should I do