An open API service indexing awesome lists of open source software.

https://github.com/vitberget/git-prompt


https://github.com/vitberget/git-prompt

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

          

# Git prompt

## Install

```sh
cargo install --path .
```

Should be installed to `~/.cargo/bin` on Linux.

## Use

Git prompt gives output like output:

```
export GIT_PROMPT_BRANCH=main
export GIT_PROMPT_INDEX_CHANGED=false
export GIT_PROMPT_WORKTREE_CHANGED=false
export GIT_PROMPT_REMOTE=different
```

To use it in Bash/Zsh/other:

```sh
eval $(git-prompt)
```

### Zsh example

```zsh
function git-prompt-prompt() {
eval $(git-prompt)
if [[ ! -z "$GIT_PROMPT_BRANCH" ]]; then
if [[ "$GIT_PROMPT_REMOTE" == "same" ]]; then
echo -n "%F{249}\uE0A0${GIT_PROMPT_BRANCH}"
else
echo -n "%F{160}\uE0A0%F{249}${GIT_PROMPT_BRANCH}"
fi
if [[ "$GIT_PROMPT_INDEX_CHANGED" == "true" ]]; then
echo -n "%F{red}✗"
else
echo -n "%F{green}✓"
fi
if [[ "$GIT_PROMPT_WORKTREE_CHANGED" == "true" ]]; then
echo -n "%F{red}✗"
else
echo -n "%F{green}✓"
fi
echo " "
fi
}
```

## References

### Crate: git2

*
*
*