lukesampson / pshazz

Give your powershell some pizazz.
The Unlicense
577 stars 40 forks source link

git prompt not showing, reverting to "PS>" instead #36

Closed eugenesvk closed 8 years ago

eugenesvk commented 8 years ago

I'm using a freshly (re)installed pshazz with an empty profile (with only one line try { $null = gcm pshazz -ea stop; pshazz init 'default' } catch { } injected during installation), default theme and I do get colored prompt outside of git folders. However, whenever I enter a git folder I just get PS>. That's not much to go on, I understand, but I'm just as puzzled and have no clue where exactly it's breaking down. Any hints on what could cause this or at least how to isolate the issue?

Update: funny thing is when I execute pshazz_write_prompt $global:pshazz.theme.prompt $global:pshazz.prompt_vars from the command line I can see the resulting prompt just fine, showing cyan path, red master plus a few symbols and the $ sign. Yet, for some reason this function doesn't seem to get executed automatically even though it is part of the global:prompt function, which implies it should get executed automatically (and it does so outside of git folders). Is there some kind of break-point in those functions that prevents an output in case of some internal error or failing some other condition check?

Windows 10.0.10586.0 PowerShell 5.0

lukesampson commented 8 years ago

Maybe the git plugin for pshazz isn't compatible with your version of git?

If you enable Powershell debugging with set-psdebug -trace 1, does that show you any errors? Run set-psdebug -off to turn debugging off.

Also, what happens if you switch to the lukes theme (pshazz use lukes)? That has a simplified git prompt.

If switching the lukes theme works, you might want to edit the default theme to play with the git and prompt settings to see what works. You can do that with

mkdir ~/pshazz
pshazz edit default
# ... make some changes ...
pshazz use default
eugenesvk commented 8 years ago

After opening Powershell and running your debug command and then entering a git folder, I get nothing but the DEBUG: 1+ code with my command. Otherwise no errors on entering/leaving the git folder.

After switching to lukes I got hundreds of lines like that DEBUG: X+ which seem to just output all the theme lines. But I don't know what an error would look like (a specific Debug code?). Unfortunately, that didn't help either, lukes theme still reverts to PS>

I have git version 2.7.3 used within Msys2, though that didn't stop posh-git or any of my other addons (e.g. clink in command prompt) from displaying git information. Also, if git version were incorrect, then the manual invocation of pshazz_write_prompt $global:pshazz.theme.prompt $global:pshazz.prompt_vars wouldn't show anything, would it?

I've found the default theme file and already tried to tweak it a bit with patched glyphs (I just want to replicate my fish theme https://github.com/oh-my-fish/theme-es), though the way you draw prompt seems to ignore them, I get  instead of proper symbols, likely the string functions you're using are not Unicode or something, but that's a separate issue.

eugenesvk commented 8 years ago

Here is the debug info after I try the pshazz use lukes command just in case http://pastebin.com/CpAErJtM

lukesampson commented 8 years ago

Check out #33 for using special characters.

Yeah sorry, I was thinking to turn off debugging before you switch to lukes, just to see if you get something other than PS>.

Maybe Powershell doesn't let you debug the prompt. Maybe you could turn off debugging and see what running prompt gives you when run from inside a git repo. I get an error about no .hg repo—the prompt function just swallows these errors, but maybe this will give you some insight.

eugenesvk commented 8 years ago

Running prompt is a good idea, here are the errors

fatal: ambiguous argument '@u': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument '@u...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
You cannot call a method on a null-valued expression.
At C:\dev\apps\pshazz\0.2015.11.13\plugins\git.ps1:111 char:22
+             $remote_array = @($remote.split());
+                               ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

AheadBehind master* $
eugenesvk commented 8 years ago

Also, the https://github.com/lukesampson/pshazz/issues/33 didn't work for me :( Strange though, I can copy&paste these symbols directly and they are working perfectly fine in echo, printf or Write-Host commands. And pasting this code directly (e.g. "$([char]0xF06B)" with or without quotes) works fine!

lukesampson commented 8 years ago

Can you try updating pshazz with scoop update pshazz and see if that fixed it?

eugenesvk commented 8 years ago

Tried already, it is fixed, thank you! Would you kindly advise how to fix the special characters as well? Tried to follow the var assignments that are subsequently used in drawing your prompt, but didn't understand where it fails. In my tests assigning a variable special char in either format works as is

lukesampson commented 8 years ago

Cool. See my comment in #33.