jasongin / nvs

Node Version Switcher - A cross-platform tool for switching between versions and forks of Node.js
Other
2.7k stars 210 forks source link

Issue with nvs auto clearing PowerShell prompt #161

Open bytenik opened 4 years ago

bytenik commented 4 years ago

I have the following PowerShell profile:

# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
  Import-Module "$ChocolateyProfile"
}

function Prompt
{
  $location = $(get-location)
  $host.ui.RawUI.WindowTitle = $location
  "${location}>"
}

nvs auto on

Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Agnoster

nvs's auto feature does not get enabled somehow. If I then use nvs auto on, my prompt is replaced with the standard default:

 ⨯ bytenik@BYTENIK-PC  D:\..\..\..\platform-ws   dev ≣  nvs auto on
PATH -= $env:LOCALAPPDATA\nvs\node\10.9.0\x64
PATH -= $env:LOCALAPPDATA\nvs\default
PATH += $env:LOCALAPPDATA\nvs\node\13.14.0\x64
D:\Documents\Projects\thinkalpha\platform-ws>
ontoneio commented 3 years ago

Having similar issues with this clearing out my prompt settings. Specifically my posh-git stuff seemingly gets wiped and I lose context.

nvs auto on does not seem to work in any case I have tried. only nvs auto has worked which is still helpful.

jasongin commented 3 years ago

nvs auto on hooks into PowerShell's prompt function so that it can detect directory changes. It will take some investigation to understand whether it's possible to make that work in a way that plays nicely with posh-git.

dsbert commented 3 years ago

I use starship which is a custom prompt. With the following profile, they both seem to work fine together.

# Improved prompt
Invoke-Expression (&starship init powershell)
Write-Host -Foreground Green "Initialized Starship."

# Activate nvs after starship to preserve the custom prompt
nvs auto on

@bytenik Did you try moving nvs auto on to the bottom of your profile?

bytenik commented 3 years ago

I can't do that because nvs auto on clobbers the prompt:

See this copy/paste from my console when I run it:

 bytenik@BYTENIK-PC  D:\..\..\platform-ws   dev ≣  nvs auto on
Adding: node/15/x64
Downloading [#####################################################################################################################################] 100%
Extracting  [#####################################################################################################################################] 100%
PATH -= $env:LOCALAPPDATA\nvs\default
PATH += $env:LOCALAPPDATA\nvs\node\15.5.0\x64
D:\Documents\Projects\platform-ws>
whschultz commented 1 year ago

I can confirm that the recent version 1.7.0 fixed this issue for me with Starship. nvs does need to be loaded after Starship.