From c8e58f272e1544cab6ea36f8c4df92953225b449 Mon Sep 17 00:00:00 2001 From: John Fultz Date: Sun, 25 Nov 2018 07:20:19 -0600 Subject: [PATCH] Documentation for use in bash, tcc. --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 1d4732b..bb06c22 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,33 @@ A personal project to create a decent git prompt in Rust. # Background I need a replacement for the quite nice bash git prompt, which is just too slow on Windows. Also I like to use other shells on Windows including `cmd` and `tcc`. And this has become an opportunity for me to learn Rust. +# Usage + +### bash +E.g., here's what I'm using right now... +``` +# Setup variables for the binary and the non-git portions of the prompt +export GIT_PROMPT_BINARY= +export GIT_PROMPT_START="${COLOR_GRAY}\T ${COLOR_BLUE}\h:${COLOR_GREEN}\w${COLOR_NONE} " +export GIT_PROMPT_END="\n>" + +# This is executed by bash before each prompt, and it resets PS1 to +# be updated based upon the current state of the shell, assuming +# GIT_PROMPT_BINARY is valid. +set_prompt() { + if [[ -e $GIT_PROMPT_BINARY ]]; then + export PS1="${GIT_PROMPT_START}`${GIT_PROMPT_BINARY}`${GIT_PROMPT_END}" + fi +} +export PROMPT_COMMAND='set_prompt' +``` + +### TCC +E.g., here's what I'm using right now... +``` +SET GIT_PROMPT_BINARY= +prompt `$e[1;30m$M $e[0;34m%COMPUTERNAME $e[0;32m$P$e[0m %@execstr[%GIT_PROMPT_BINARY]$_$g` +``` + # License [MIT License](LICENSE). This project uses [libgit2](https://libgit2.github.com/) via [git2-rs](https://github.com/alexcrichton/git2-rs) (and also imports many other dependencies of the git2 crate which I won't specifically call out).