diff --git a/README.md b/README.md index 5c7f5b1..7f8131b 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ staged, changed, etc. (an original idea from this [blog post][]). -`gitstatus.sh` added by [AKS](http://github.com/aks). +`gitstatus.sh` and `git-prompt-help.sh` added by [AKS](http://github.com/aks). ## Examples -The prompt may look like the following: +The prompt may look like the following: ![Example prompt](gitprompt.png) @@ -49,9 +49,13 @@ The symbols are as follows: ## Install -- Clone this repository to your homedir - e.g. ``git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt`` -- Source the file ``gitprompt.sh`` from your ``~/.bashrc`` config file: +1. Clone this repository to your home directory. + + git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt + +2. Source the file `gitprompt.sh` from `~/.bashrc` + +3. `cd` to a git repository and test it! ```sh # some other config in .bashrc @@ -61,28 +65,40 @@ The symbols are as follows: # Set config variables first GIT_PROMPT_ONLY_IN_REPO=1 + # GIT_PROMPT_FETCH_REMOTE_STATUS=0 # uncomment to avoid fetching remote status + + # GIT_PROMPT_START=... # uncomment for custom prompt start sequence + # GIT_PROMPT_END=... # uncomment for custom prompt end sequence + # as last entry source the gitprompt script source ~/.bash-git-prompt/gitprompt.sh ``` - Go in a git repository and test it! -## Configuration +- You can define `GIT_PROMPT_START` and `GIT_PROMPT_END` to tweak your prompt. -- The default colors and some variables for tweaking the prompt are defined - within ``gitprompt.sh``, but may be overridden by copying ``git-prompt-colors.sh`` - to your home directory at ``~/.git-prompt-colors.sh``. This file may also be found in the same - directory as ``gitprompt.sh``, but without the leading ``.``. +- The default colors are defined within `prompt-colors.sh`, which is sourced by + `gitprompt.sh`. The colors used for various git status are defined in + `git-prompt-colors.sh`. Both of these files may be overridden by copying + them to $HOME with a `.` prefix. They can also be placed in `$HOME/lib` + without the leading `.`. The defaults are the original files in the + `~/.bash-git-prompt` directory. -- You can use ``GIT_PROMPT_START_USER``, ``GIT_PROMPT_START_ROOT``, ``GIT_PROMPT_END_USER`` and ``GIT_PROMPT_END_ROOT`` in your ``.git-prompt-colors.sh`` to tweak your prompt. You can also override the start and end of the prompt by setting ``GIT_PROMPT_START`` and ``GIT_PROMPT_END`` before you source the ``gitprompt.sh`` +- You can use `GIT_PROMPT_START_USER`, `GIT_PROMPT_START_ROOT`, + `GIT_PROMPT_END_USER` and `GIT_PROMPT_END_ROOT` in your + `.git-prompt-colors.sh` to tweak your prompt. You can also override the start + and end of the prompt by setting `GIT_PROMPT_START` and `GIT_PROMPT_END` + before you source the `gitprompt.sh`. - The current git repo information is obtained by the script `gitstatus.sh` or - `gitstatus.py`. Both scripts do the same thing, but the bash script is a - tad more quick, and is used by default. If you prefer the python script - (possibly because you have enhanced it), simply delete or change the name of - ``gitstatus.sh``. + `gitstatus.py`. Both scripts do the same thing, but the bash script is a tad + more quick, and is used by default. If you prefer the python script + (possibly because you have enhanced it), simply delete or change the name of + `gitstatus.sh`. + +- You can define `prompt_callback` function to tweak your prompt dynamically. -- You can define ``prompt_callback`` function to tweak your prompt dynamically. ```sh function prompt_callback { if [ `jobs | wc -l` -ne 0 ]; then @@ -91,19 +107,26 @@ function prompt_callback { } ``` -- If you want to show the git prompt only, if you are in a git repository you can set ``GIT_PROMPT_ONLY_IN_REPO=1`` before sourcing the gitprompt script +- If you want to show the git prompt only if you are in a git repository you + can set ``GIT_PROMPT_ONLY_IN_REPO=1`` before sourcing the gitprompt script -- You can show an additional indicator at the start of the prompt, which shows the result of the last executed command by setting ``GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR=1`` before sourcing the gitprompt script +- You can show an additional indicator at the start of the prompt, which shows + the result of the last executed command by setting + ``GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR=1`` before sourcing the gitprompt + script -- It is now possible to disable the fetching of the remote repository either globally by setting ``GIT_PROMPT_FETCH_REMOTE_STATUS=0`` in your .bashrc or - on a per repository basis by creating a file named ``.bash-git-rc`` with the content ``FETCH_REMOTE_STATUS=0`` in the root of your git repository. +- It is now possible to disable the fetching of the remote repository either + globally by setting ``GIT_PROMPT_FETCH_REMOTE_STATUS=0`` in your .bashrc or + on a per repository basis by creating a file named ``.bash-git-rc`` with the + content ``FETCH_REMOTE_STATUS=0`` in the root of your git repository. - You can get help on the git prompt with the function ``git_prompt_help``. - Examples are available with ``git_prompt_examples``. + Examples are available with ``git_prompt_examples``. **Enjoy!** ## Alternative RPM Install + This project ships an RPM spec to simplify installation on RHEL and clones. If you wish to install from RPM, you may first build the RPM from scratch by following this procedure: