zpr 中文文档教程
zpr
zpr(发音为 zeper 或 /ˈziːpər/)是一个 Node 模块,它提供了一种简单的编程方式来构造 zsh 提示符。
安装
npm i zpr
使用
import Prompt from 'zpr';
const prompt = new Prompt()
.colorOpen('red')
.text('[')
.cwdFromHome()
.text(']')
.colorClose()
.text(' $ ');
console.log(prompt.toString());
即插即用提示
- transpicously
- 做了一个吗?打开 PR 让我知道!
常见问题解答
我该如何使用它?
要在终端左侧设置提示,请将以下内容添加到 ~/.zshrc
中:
PROMPT="$(node /path/to/your/script.js)"
要在终端右侧设置提示,请将以下内容添加到 ~ /.zshrc
:
RPROMPT="$(node /path/to/your/script.js)"
如果您在提示中使用替换,则需要使用单引号而不是双引号。
为什么?
允许从 Node 内轻松创建 zsh 提示符,而不必搞乱讨厌的 shell 脚本和百分号。
CLI 支持吗?
不,目前还没有 CLI 支持。如果您想在 shell 中使用 zpr,则必须编写一个包装脚本。不过,我确实计划在将来添加 CLI。
zpr
zpr (pronounced zeper or /ˈziːpər/) is a Node module that provides a simple programmatic way to construct zsh prompts.
Installation
npm i zpr
Usage
import Prompt from 'zpr';
const prompt = new Prompt()
.colorOpen('red')
.text('[')
.cwdFromHome()
.text(']')
.colorClose()
.text(' $ ');
console.log(prompt.toString());
Plug-n-Play Prompts
- transpicuous
- Made one? Open a PR and let me know!
FAQ
How can I use this?
To set a prompt on the left side of your terminal, add the following to your ~/.zshrc
:
PROMPT="$(node /path/to/your/script.js)"
To set a prompt on the right side of your terminal, add the following to your ~/.zshrc
:
RPROMPT="$(node /path/to/your/script.js)"
If you use substitutions in your prompt, you'll need to use single quotes instead of double quotes.
Why?
To allow the easy creation of zsh prompts from within Node, instead of having to mess around with pesky shell scripts and percent signs.
CLI Support?
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.