djs / clink-gitprompt

A git prompt implementation for cmd.exe implemented as a clink filter
16 stars 3 forks source link

Separated lib and prompt filter #1

Closed samvasko closed 10 years ago

samvasko commented 10 years ago

This way the repo can also be used as a dependency in cmder where there is some extra stuff to be done before it can be added to the prompt

Somehow github did not recognize my moving, despite I git mv. So the diff looks bit messed up. Sorry for that.

djs commented 10 years ago

Are you able to get this to work at a raw cmd.exe prompt? When I dropped the two scripts into the clink directory, I got an error:

  C:\Users\dan\AppData\Local.\clink\git_prompt.lua:1: module 'git_prompt_lib' not found:
          no field package.preload['git_prompt_lib']
          no file 'C:\WINDOWS\SYSTEM32\lua\git_prompt_lib.lua'
          no file 'C:\WINDOWS\SYSTEM32\lua\git_prompt_lib\init.lua'
          no file 'C:\WINDOWS\SYSTEM32\git_prompt_lib.lua'
          no file 'C:\WINDOWS\SYSTEM32\git_prompt_lib\init.lua'
          no file '.\git_prompt_lib.lua'
          no file 'C:\WINDOWS\SYSTEM32\git_prompt_lib.dll'
          no file 'C:\WINDOWS\SYSTEM32\loadall.dll'
          no file '.\git_prompt_lib.dll'
samvasko commented 10 years ago

I did but not at the current commit. Did you also copy git_prompt_lib.lua?

djs commented 10 years ago

I did. I just tried copying it into C:\Windows\System32\lua and that worked. So, it seems like . is not referring to the same location in the error above. I'll see if I can figure it out tomorrow.

djs commented 10 years ago

The original problem went away, but now I've found that when I use this version, it works on the first attempt inside a git repo, but then fails every time I press enter thereafter. I don't see this with the original version.

C:\Users\dan\dev\clink-gitprompt> (master)
C:\Users\dan\AppData\Local.\clink\git_prompt.lua:4: attempt to call field 'git_ps1' (a nil value)

So, still no idea what's going on, but I'll keep investigating.

djs commented 10 years ago

Looks like this is a consequence of the way clink registers the filter. After the first call, it can no longer reference the imported module. So, I just moved the require call inside the function itself.

djs commented 10 years ago

Well, now I know why it started working. I had forgotten to delete the copy I put in c:\windows\system32\lua. So, the require search path issue is still a problem. I'm going to revert the changes in master until we have a working solution.