zpr (pronounced zeper or /ˈziːpər/) is a Node module that provides a simple programmatic way to construct zsh prompts.
npm i zpr
import Prompt from 'zpr';
const prompt = new Prompt()
.colorOpen('red')
.text('[')
.cwdFromHome()
.text(']')
.colorClose()
.text(' $ ');
console.log(`PROMPT="${prompt.toString()}"`);
- transpicuous
- Made one? Open a PR and let me know!
To set a prompt on the left side of your terminal, add the following to your ~/.zshrc
:
eval $(node /path/to/your/script.js)
To set a prompt on the right side of your terminal, add the following to your ~/.zshrc
:
eval $(node /path/to/your/script.js)
If you use substitutions in your prompt, you'll need to use single quotes instead of double quotes.
To allow the easy creation of zsh prompts from within Node, instead of having to mess around with pesky shell scripts and percent signs.
No, there is no CLI support (yet). If you want to use zpr in your shell, you'll have to write a wrapper script. However, I do plan on adding a CLI in the future.