nvs icon indicating copy to clipboard operation
nvs copied to clipboard

Issue with nvs auto clearing PowerShell prompt

Open bytenik opened this issue 4 years ago • 5 comments

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>

bytenik avatar May 28 '20 16:05 bytenik

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.

ontoneio avatar Sep 09 '20 22:09 ontoneio

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.

jasongin avatar Sep 10 '20 16:09 jasongin

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?

dsbert avatar Dec 20 '20 16:12 dsbert

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>

bytenik avatar Dec 23 '20 15:12 bytenik

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.

whschultz avatar Mar 28 '23 20:03 whschultz