Hello. I think pure is awesome, I want to use it everywhere.
The README made me think that installing pure on a server without npm or root access would be too cumbersome to do several times a day. After looking closer, I see that it's actually quite easy to automate--but it would be even easier if small changes were made to this repo.
Here is the install process as documented
1. pull pure from github
2. examine fpath
3. add a symlink in fpath to pure.zsh
4. add a symlink in fpath to async.zsh
5. modify zshrc:
autoload -U promptinit; promptinit
prompt pure
But this works too:
1. pull pure from github into <pure_dir>
2. copy `pure.zsh` to `prompt_pure_setup`
3. copy `async.zsh` to `async`
4. modify .zshrc:
fpath+=("<pure_dir>")
autoload -U promptinit; promptinit
prompt pure
Steps 2 and 3 could be eliminated by either:
prompt_pure_setup so that it looks for pure.zsh too (and likewise for async)So the resulting install would just be:
1. pull pure from github into <pure_dir>
2. modify .zshrc:
fpath+=("<pure_dir>")
autoload -U promptinit; promptinit
prompt pure
The modifications above would also be helpful for cases where the user uses git to sync parts their home directory between servers (like I do). As it stands, my zshrc contains this monster:
# pure prompt (https://github.com/sindresorhus/pure)
PROMPT_DIR="$HOME/.zsh/pure"
PROMPT_SETUP_IN="$HOME/.zsh/pure/pure.zsh"
PROMPT_SETUP="$HOME/.zsh/pure/prompt_pure_setup"
PROMPT_ASYNC_IN="$HOME/.zsh/pure/async.zsh"
PROMPT_ASYNC="$HOME/.zsh/pure/async"
if [ -d "$PROMPT_DIR" ] ; then
# If the pure submodule has been fetched
# align the setup files with pure's expectations
if [ ! -f "$PROMPT_SETUP" ] ; then
cp -v "$PROMPT_SETUP_IN" "$PROMPT_SETUP"
fi
if [ ! -f "$PROMPT_ASYNC" ] ; then
cp -v "$PROMPT_ASYNC_IN" "$PROMPT_ASYNC"
fi
# the set the path to pure
fpath+=("$HOME/.zsh/pure")
autoload -U promptinit; promptinit
prompt pure
else
echo "$PROMPT_DIR does not exist, consider running: git submodule update --init"
fi
If pure implemented a recommendation from above, then I could simplify it significantly and still use pure on a fresh server without any additional commands (besides the usual git init git remote add <home> and git submodule update --init).
Also, even ignoring my particular case, I think it's worth doing because it would simplify the setup process for other users (especially those without root access).
Thank You
@mattrixman thanks for the suggestion. I'm not sure we want to rename the files (e.g. we want to keep the extension), however, we could use symlinks instead. Would you be interested in submitting a PR with symlinks and appropriate changes to the readme?
I would like to make a PR for this. How would you like the installation instructions to be modified though?
Presently, the first step itself offers three options. I think only retaining the first and third options, additionally specifying the directory and then proceeding directly to Getting Started is what would be best.
Here is what that would look like:
Either clone the repo or just download pure.zsh and async.zsh into
Initialize the prompt system and choose pure:
# .zshrc
fpath+=("<pure_dir>")
autoload -U promptinit; promptinit
prompt pure
I've left out mentions of a submodule installation as it is not something I'm familiar with though I think it is important to mention that it is a possibility. How should I do that?
Sorry for failing to get back to this. Somehow I lost track of it between the work github profile and the personal one (I'm also @mattrixman).
@lokesh-krishna I like your instructions, but they will only work if async and prompt_pure_setup, which they currently don't. I have created https://github.com/sindresorhus/pure/pull/419 which adds them. If that PR is accepted, then I think your instructions will be just fine.
I didn't realize git could handle symlinks, thanks @mafredri for pointing that out. I also like the idea of including those in the repo. It is a much more elegant solution to my problem than what I came up with.
When I started this issue, I didn't understand that zsh requires the filename in fpath to be the name of the function that it contains, and that further, pure.zsh is not a valid function name. So I was hoping for a change that caused zsh to pick the function directly out of the files as they were--but now I see that that's just not how zsh works.
I think that using git to sync your dotfiles is pretty awesome, and I recommend it to people. If you're using git to sync your .zshrc across machines, then it makes sense to include pure as a submodule and then sync it too.
Anybody who is already using submodules to sync functionality alongside configuration will be able to figure out how to use a submodule to achieve this with pure (the process is identical to what pathogen uses, described here). Anybody who doesn't do this, would probably just be confused by the extra verbiage in the readme. If I included anything about this at all, I'd probably just say:
If you use git to sync your .zshrc then you might consider making
a submodule, so you can sync pure with git too.
But honestly, I'd probably not mention it explicitly. With the above PR, anybody who cares about that functionality will be able to figure it out.
For anyone that wants to work on this, see the initial attempt and feedback in https://github.com/sindresorhus/pure/pull/419.