#prompt #shell-prompt #shell #themes #cli

app pista

为程序员设计的简单bash提示符

5 个版本

0.1.5 2021年4月12日
0.1.3 2020年8月17日
0.1.2 2020年7月10日
0.1.1 2019年7月9日
0.1.0 2019年5月21日

#449 in 配置

每月 26 次下载

MIT 许可证

15KB
264

pista

为程序员提供的简单{bash, zsh}提示符

pista.png

功能

  • 缩短当前工作目录
  • git信息(分支/提交,领先/落后状态,仓库状态)
  • 超级用户指示符
  • 完全可配置
  • m̶̛̩̬͎̲͚͙͇͂͌̏͒̎͗̆̚i̡̛̬̩͙̣̤͈̥̟͔͆̈͑̑͠͝ņ̵̛̟̥̹͍̻͍̐͛̑͋ì̴̛̗̫͍̯͈̖̝͍͊̏͗̍̈́̾m̨̼̦͈͍͕͊̀̾̽̿̅͋͆͜a̵͔̥̫̲͙͒̎͋͌̑͘̚͜͡l̵̨̧̛̪̭̣͚͇͌̇͋̌͘͢

安装

  • 步骤 0:安装 rust
$ curl https://sh.rustup.rs -sSf | sh
Rust is installed now. Great!

# check if you have the latest version. 
# pista works with rustc >= 1.34
$ rustc --version
rustc 1.36.0 (a53f9df32 2019-07-03)

# update rust if required
$ rustup update
  • 步骤 1a(从crates.io安装):使用 cargo(Rust的包管理器)安装 pista
# if you want to install from source, skip over to 1b
$ cargo install pista

$ ~/.cargo/bin/pista -V
Pista 0.1.2
# yay!
  • 步骤 1b(从源代码安装):如果您不想从crates.io安装,可以从源代码安装
# install from source
$ git clone https://github.com/nerdypepper/pista --recurse-submodules
$ cargo install --path ./pista --force

$ ~/.cargo/bin/pista -V
Pista 0.1.2
# yay!
  • 步骤 2a(bash):bash用户,设置您的 PS1
PS1='$(pista)'    # regular variant
PS1='$(pista -m)' # minimal variant
  • 步骤 2b(zsh):zsh用户,将其添加到您的 .zshrc
autoload -Uz add-zsh-hook
_pista_prompt() {
	PROMPT="$(pista -z)"   # `pista -zm` for the miminal variant
}
add-zsh-hook precmd _pista_prompt

pista 处理虚拟环境中的提示符修改。请确保禁用 virtualenv 的更改。

export VIRTUAL_ENV_DISABLE_PROMPT=1

就这样!如果您对默认设置不满意,请继续阅读。

配置

这是默认配置。将其放入您的 .bashrc(或 .zshrc)以开始。请记住,为了观察更改,请执行 source ~/.bashrc(或 source ~/.zshrc)!

# prompt string to display, for regular users
export PROMPT_CHAR="$"
export PROMPT_CHAR_COLOR="green"

# prompt string to display, for the root user
export PROMPT_CHAR_ROOT="#"
export PROMPT_CHAR_ROOT_COLOR="red"

# if SHORTEN_CWD is set to 1, `/home/nerdypepper/code` is shortened to
# `/h/n/code`
export SHORTEN_CWD=1
export CWD_COLOR="white"

# if EXPAND_TILDE is set to 0, `/home/nerdypepper` is shortened to `~`
export EXPAND_TILDE=0

# there are three possible states for a git repo
# - unstaged (working tree has been modified) 
# - staged (staging area has been modified)
# - clean (all staged changes have committed)

# symbol to represent clean repo state
export GIT_CLEAN="·"
export GIT_CLEAN_COLOR="green"

# symbol to represent unstaged repo state
export GIT_WT_MODIFIED="×"
export GIT_WT_MODIFIED_COLOR="red"

# symbol to represent staged repo state
export GIT_INDEX_MODIFIED="±"
export GIT_INDEX_MODIFIED_COLOR="yellow"

# if HEAD ref peels to branch
export BRANCH_COLOR="green"

# if HEAD ref peels to a commit (detached state)
export COMMIT_COLOR="green"

所有16种颜色都可用

black
red
green
yellow
blue
magenta (or purple)
cyan
white

bright black
bright red
bright green
bright yellow
bright blue
bright magenta (or purple)
bright cyan
bright white

依赖

~9–17MB
~282K SLoC