https://github.com/vitberget/git-prompt
https://github.com/vitberget/git-prompt
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vitberget/git-prompt
- Owner: vitberget
- Created: 2023-09-15T12:00:26.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-16T11:21:31.000Z (almost 2 years ago)
- Last Synced: 2024-07-16T14:04:17.552Z (almost 2 years ago)
- Language: Rust
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
*
*
*