JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
16.79k stars 2.35k forks source link

theme doesn't shows conda env name #2792

Closed lucasjinreal closed 2 years ago

lucasjinreal commented 2 years ago

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

lucasjinreal commented 2 years ago

image

JanDeDobbeleer commented 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.

lucasjinreal commented 2 years ago
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:
JanDeDobbeleer commented 2 years ago

@jinfagang can I get the full output? This seems like only half of it.

lucasjinreal commented 2 years ago

does there a file saved? the terminal screen has a very long print

JanDeDobbeleer commented 2 years ago

@jinfagang you can pipe this to clip -> oh-my-posh debug | clip

gf9276 commented 2 years ago

I'm having the same problem

gf9276 commented 2 years ago

I use oh my posh on wsl

JanDeDobbeleer commented 2 years ago

@gf9276 same question as above, I need the logs otherwise this will get closed in a few days automatically.

lucasjinreal commented 2 years ago

don't matically, close it. I am too lazy to touch a log... but problem still un solved.

gf9276 commented 2 years ago

@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.

lucasjinreal commented 2 years ago

@gf9276 Can u verifed which theme have python segment? themes suggested by @JanDeDobbeleer certainly don't have .....

gf9276 commented 2 years ago

@jinfagang I looked at the code for all the themes, 'night-owl' is the most comprehensive.

lucasjinreal commented 2 years ago

OK, I given it up.. don't know what i missed here, but still none of theme shows conda env name.

image

whats your promot looks like?

gf9276 commented 2 years ago

Open wsl in windows terminal,like this. Seems like we're not using the same theme. Are you using 'night-owl.omp.json'? image

JanDeDobbeleer commented 2 years ago

@jinfagang you're not using a theme. The path you shared in init is incorrect.

gf9276 commented 2 years ago

@jinfagang You can write a theme yourself, plus the segments you need. I found that arrows will have some bugs in vscode, like this: image So I rewrote a theme myself based on '1_shell', and I am using this. (W8S5COPKVX (S5BWL(T7SD

lucasjinreal commented 2 years ago

@JanDeDobbeleer I am confused here:

image

I set it night-owl.

why did say not same theme? @gf9276 can u try in Powershell? I am not using wsl.

JanDeDobbeleer commented 2 years ago

@jinfagang do you have the $env:POSH_THEME_PATH variable? It's either that or the path isn't accessible for oh-my-posh.

gf9276 commented 2 years ago

@jinfagang i think you loss .omp......

gf9276 commented 2 years ago

@jinfagang night-owl.omp.json, not night-owl.json

lucasjinreal commented 2 years ago

@gf9276 thanks for reminding this. Still can not see conda env names.

image

JanDeDobbeleer commented 2 years ago

@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.

gf9276 commented 2 years ago

@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 .

lucasjinreal commented 2 years ago

@gf9276 nop. without ph my posh also can not show

gf9276 commented 2 years ago

@jinfagang It seems that it is normal that the conda environment is not displayed on the power shell,you should use anaconda prompt.

JanDeDobbeleer commented 2 years ago

@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.

gf9276 commented 2 years ago

@JanDeDobbeleer Yes, you are right.

gf9276 commented 2 years ago

@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.

VVingerfly commented 1 year ago

conda init --all solved my problem. Thanks

Hezhexi2002 commented 1 year ago

@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.

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)
JanDeDobbeleer commented 1 year ago

@Hezhexi2002 it would be good to update first. You're still on an older version.

Hezhexi2002 commented 1 year ago

@Hezhexi2002 it would be good to update first. You're still on an older version.

The problem still exists after I upgrade it: image

JanDeDobbeleer commented 1 year ago

@VVingerfly you're in the HOME folder though. The env name by default doesn't show in there (see home_enabled).

Hezhexi2002 commented 1 year ago

@VVingerfly you're in the HOME folder though. The env name by default doesn't show in there (see home_enabled).

But the env name still not shown when I change to another folder instead of HOME: image

JanDeDobbeleer commented 1 year ago

@Hezhexi2002 I see, and according to your previous debug log, I see you're using powerlevel10k which has fetching the virtual env disabled.

Hezhexi2002 commented 1 year ago

@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?

JanDeDobbeleer commented 1 year ago

@Hezhexi2002 by reading the documentation on how to adjust.

Hezhexi2002 commented 1 year ago

@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: image image

JanDeDobbeleer commented 1 year ago

@Hezhexi2002 yes, but that's also in your HOME folder which is disabled by default as well.

Hezhexi2002 commented 1 year ago

@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: image

JanDeDobbeleer commented 1 year ago

@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 commented 1 year ago

@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

JanDeDobbeleer commented 1 year ago

@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.

Hezhexi2002 commented 1 year ago

@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: image 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: image image 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

JanDeDobbeleer commented 1 year ago

@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.

github-actions[bot] commented 6 months ago

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.