Code Monkey home page Code Monkey logo

Comments (7)

anthony-brien avatar anthony-brien commented on August 23, 2024 1

For some reason Install-Module and Update-Module was stuck on 1.0.0, I used -RequiredVersion 1.1.0 and now it works! My prompt is no longer affected by z. Thanks!

from zlocation.

vors avatar vors commented on August 23, 2024

That usually indicates there is an error during the prompt command execution.
You can execute run & $Function:prompt to see the real error, that would help.

from zlocation.

anthony-brien avatar anthony-brien commented on August 23, 2024

Here's the errors I'm getting :

PS>& $Function:prompt
The property 'ErrorCount' cannot be found on this object. Verify that the property exists and can be set.
At line:4 char:9
+         $sl.ErrorCount = $global:error.Count
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

Test-IsVanillaWindow : The term 'Test-IsVanillaWindow' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:7 char:12
+         if(Test-IsVanillaWindow) {
+            ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Test-IsVanillaWindow:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Reset-CursorPosition : The term 'Reset-CursorPosition' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:13 char:9
+         Reset-CursorPosition
+         ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Reset-CursorPosition:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Write-Theme : The term 'Write-Theme' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:14 char:9
+         Write-Theme -lastCommandFailed $lastCommandFailed
+         ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Write-Theme:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

These are related to my custom prompt that uses the oh-my-posh module. It's as if running z drops that module.

from zlocation.

vors avatar vors commented on August 23, 2024

I think it's likely the same problem as #59 (comment) : oh-my-posh likely calls the private APIs and assumes that prompt is executed in the module scope (which allows to call them without exposing).

from zlocation.

rkeithhill avatar rkeithhill commented on August 23, 2024

@anthony-brien What do you get from the output of:

Get-Command prompt | % Definition

Also, it sure looks similar to the posh-git issue where we couldn't access internal functions but the change I made fixed that for posh-git without having to make those internal functions public. Hmm...

from zlocation.

anthony-brien avatar anthony-brien commented on August 23, 2024

I also use posh-git, so it might be the same issue indeed.

When I run Get-Command prompt | % Definition before invoking z:

        $lastCommandFailed = $global:error.Count -gt $sl.ErrorCount
        $sl.ErrorCount = $global:error.Count

        #Start the vanilla posh-git when in a vanilla window, else: go nuts
        if(Test-IsVanillaWindow) {
            Write-Host -Object ($pwd.ProviderPath) -NoNewline
            Write-VcsStatus
            return '> '
        }

        Reset-CursorPosition
        Write-Theme -lastCommandFailed $lastCommandFailed
        return ' '

and after invoking z:

Update-ZLocation $pwd

        $lastCommandFailed = $global:error.Count -gt $sl.ErrorCount
        $sl.ErrorCount = $global:error.Count

        #Start the vanilla posh-git when in a vanilla window, else: go nuts
        if(Test-IsVanillaWindow) {
            Write-Host -Object ($pwd.ProviderPath) -NoNewline
            Write-VcsStatus
            return '> '
        }

        Reset-CursorPosition
        Write-Theme -lastCommandFailed $lastCommandFailed
        return ' '

from zlocation.

rkeithhill avatar rkeithhill commented on August 23, 2024

Hmm, it doesn't look you've upgraded to 1.1.0. If you had, then your prompt should look like this:

Update-ZLocation $pwd
ZLocationOrigPrompt

Can you Update-Module ZLocation, reload PowerShell and see how it behaves?

from zlocation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.