JanDeDobbeleer / oh-my-posh

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

path being displayed instead of home_icon #844

Closed skreel closed 3 years ago

skreel commented 3 years ago

Prerequisites

Description

Full path being displayed instead of home_icon when in $HOME directory or any subdirectory. I tried setting home_icon manually in the config. I tried setting home_icon to something else too. Neither worked. As a work around, I am able to set a mapped_location to my home directory and have it display a ~.

I have it setup and working on another computer and the home_icon is dispalying properly. The only difference is the working computer has Powershell version 7.0.3. I can't imagine a newer version of powershell being the issue though...

Environment

Optional

Steps to Reproduce

  1. cd ~
  2. view output

Expected behavior: I expect a ~ to be displayed

Actual behavior: Full path is being displayed.

JanDeDobbeleer commented 3 years ago

@skreel we use the following env vars on Windows to identify HOME:

Can you provide their values? A new version of PowerShell can have an impact though if it no longer reports this properly :-)

skreel commented 3 years ago

OK, so I think I found the problem. On the computer that is not working a home folder is set for the user in active directory. So, the $env:HOMEDRIVE and $env:HOMEPATH combo are different than the $env:USERPROFILE. The computer that is working is not on the windows domain and does not get a home folder set by active directory.

On not working computer: $env:HOMEDRIVE => H: $env:HOMEPATH => \ $env:USERPROFILE => C:\Users\UserName $env:HOME => C:\Users\UserName

On working computer: $env:HOMEDRIVE => C: $env:HOMEPATH => \Users\UserName $env:USERPROFILE => C:\Users\UserName $env:HOME => C:\Users\UserName

On the "not working" computer when I navigate to H:\ I get the tilde. When I navigate to C:\Users\UserName I do not. I would expect to get it for the later as that's where you start when you open a new powershell prompt.

Looking at the code, it appears that things are functioning as they should (according to the code.) It looks like the code only uses $env:USERPROFILE if $env:HOMEDRIVE and $env:HOMEPATH are empty strings.

Should the shell be checked for powershell and use the $env:HOME, like it is for bash? I don't know the idiosyncrasies of all these environment variables and what should be the home drive when there are differences. I do know when I run the following command "cd ~" it takes me to C:\users\UserName on both the working and not working setups. So, I would think we would want to align with that?

Thanks for your help!

JanDeDobbeleer commented 3 years ago

@skreel I do believe it makes sense that IF $HOME is set, we default to that one first. The others are for older Powershell versions anyways. Will fix.

JanDeDobbeleer commented 3 years ago

@skreel should be fixed.

github-actions[bot] commented 7 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.