e.g. ``git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt``
e.g. ``git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt``
2. Source the file ``gitprompt.sh`` from your ``~/.bashrc`` config file:
- Source the file ``gitprompt.sh`` from your ``~/.bashrc`` config file:
```bash
```sh
# some other config in .bashrc
# some other config in .bashrc
# gitprompt configuration
# gitprompt configuration
# Set config variables first
GIT_PROMPT_ONLY_IN_REPO=1
# as last entry source the gitprompt script
source .bash-git-prompt/gitprompt.sh
source .bash-git-prompt/gitprompt.sh
```
```
3. Go in a git repository and test it!
- Go in a git repository and test it!
## Configuration
## Configuration
1. The default colors and some variables for tweaking the prompt are defined
- 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``
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
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 ``.``.
directory as ``gitprompt.sh``, but without the leading ``.``.
2. 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``
3. The current git repo information is obtained by the script `gitstatus.sh` or
- 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
`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
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
(possibly because you have enhanced it), simply delete or change the name of
``gitstatus.sh``.
``gitstatus.sh``.
4. You can define ``prompt_callback`` function to tweak your prompt dynamically.
- You can define ``prompt_callback`` function to tweak your prompt dynamically.
```sh
```sh
function prompt_callback {
function prompt_callback {
if [ `jobs | wc -l` -ne 0 ]; then
if [ `jobs | wc -l` -ne 0 ]; then
@ -85,7 +91,9 @@ function prompt_callback {
}
}
```
```
5. You can get help on the git prompt with the function ``git_prompt_help``.
- 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 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``.