Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt expects external undocumented git_prompt_* functions #2

Open
antoineco opened this issue Feb 23, 2017 · 12 comments
Open

Prompt expects external undocumented git_prompt_* functions #2

antoineco opened this issue Feb 23, 2017 · 12 comments

Comments

@antoineco
Copy link

I was trying to use this prompt on a fresh setup (zsh 5.3.1), but without pulling a module which includes git_prompt_info and git_prompt_status the following errors are thrown:

prompt_purity_precmd:4: command not found: git_prompt_info                                                              
prompt_purity_precmd:4: command not found: git_prompt_status
 
zsh: command not found: git_prompt_info
zsh: command not found: git_prompt_status

Zsh doesn't include such a module by default, neither do frameworks like Zim. Maybe it would be a good idea to document that?

and thanks for the great fork!

@therealklanni
Copy link
Owner

Thanks for the report! I will look into a possible fix, or failing that I'll at least document the incompatibility.

@therealklanni
Copy link
Owner

After looking into it, I can see that git_prompt_info is a lib provided with Oh My ZSH (possibly others). It doesn't seem worthwhile to include a copy of the script in this theme as a fallback (I would then have to maintain updates to the script), and I don't immediately see any other resolution.

For now I will update the README with a note about it. Thanks again, this should help some others out if they're installing on a fresh copy of ZSH (without Oh My ZSH or another framework that happens to also include the lib).

Feel free to send me a PR updating the README with information on what you had to install to work around it, I'd appreciate that.

@antoineco
Copy link
Author

Oh no of course you shouldn't add a copy! As you said I was just thinking about adding a note to the README with some prerequisites. I can send a PR 👍

@antoineco
Copy link
Author

antoineco commented Mar 22, 2017

My bad, you did already in 6837073. I don't think it's necessary to add more information, people should either use a framework (one the these referenced at the end of the README) or copy the module from one of these frameworks.

@danarnold
Copy link

Here are some quick instructions on getting it to work. This was tested with a stock zsh 5.2 installation with only purity prompt installed on a Macbook Pro.

  1. Download https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/git.zsh
  2. Move to a directory, e.g. ~/.zshlib
  3. chmod a+x file
  4. Add source /path/to/git.zsh to your .zshrc

@antoineco
Copy link
Author

@danarnold a more idiomatic way is to simply add it to your fpath (echo $fpath), and make it "auto-loadable" with autoload -Uz git_prompt_info, autoload -Uz git_prompt_status. It will then be loaded only when purity needs it, speeding up the initialisation of Zsh.

Actually it would be even better if @therealklanni could add these autoload statements to purity directly :) cf. purity.zsh, line 91

@danarnold
Copy link

Yeah, I think it makes sense to bundle it with the prompt, since it's a hard dependency that will throw errors if not installed.

I had tried to get it working in my fpath after a quick Google search, but I saw someone on StackOverflow claiming that in order to be loaded with autoload, each function should live in its own file; however, the functions above are all written in a single file. I admittedly didn't test both situations, I just got it working as quick as I could. I'll give that a shot later, thanks for the more idiomatic way; I'm not normally a zsh user.

@antoineco
Copy link
Author

Ah, fair point regarding the autoload built-in! So to make it short it works only with Oh-My-Zsh unless one does the manipulation you explained. Sad :(

@therealklanni
Copy link
Owner

Thanks for the input, guys!

Admittedly, I'm not that experienced with ZSH customization, I just made some minor changes to the Pure theme from Sindre Sorhus.

If you guys (or anyone) comes up with a good solution, I will be happy to implement it, or accept a PR.

🤘

@therealklanni
Copy link
Owner

For now, I will leave the README as is, since I linked it to this thread already people can see your great solutions here if they need it.

@manvithn
Copy link

I found a fairly simple solution for zgen. You can update the .zshrc file with the following:

zgen oh-my-zsh
zgen load therealklanni/purity

The first line loads oh-my-zsh base modules, which includes the functionality the theme requires.

@therealklanni
Copy link
Owner

Thanks for posting, @manvithn. I hope this is helpful for others. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants