With git-prompt
you'll hopefully never find yourself again in the following gruesome situations:
- Resolving merge conflicts manually because you forgot to
pull
your branch. - or even worse,
commiting
andpushing
to the wrong branch 😱
Easy to install, just two simple steps:
git clone -q https://github.com/ezorita/git-prompt
printf "\nsource $(pwd)/git-prompt/git-prompt" >> ~/.bashrc
git clone -q https://github.com/ezorita/git-prompt
printf "\nsource $(pwd)/git-prompt/git-prompt" >> ~/.bash_profile
It's terribly simple:
Automatically turns on when you cd
in a git repository.
Working directory in prompt is relative to your repository root.
No need to fetch
anymore. It will automatically fetch
your current branch every 10 (default) minutes.
Automatically fetches
when you cd
to a git repository or change branch.
Alerts when the last fetch
has failed.
Type GIT_PROMPT=0
or gitpr
and voilà, you're back to your default prompt.
Here is the alias definition, add it to your bash options file:
alias gitpr='GIT_PROMPT=$((1-{$GIT_PROMPT}))'
Just set the environment variables.
Options can be set directly in the terminal or, if you want to set them permanently, define them anywhere in your .bashrc
or .bash_profile
file:
Parameter | Description |
---|---|
GIT_PROMPT | Enables/disables git-prompt (values 1 /0 ) [default 1 ] |
GIT_AUTOFECTH | Enables/disables autofecth (values1 /0 ) [default 1 ] |
GIT_AUTOFECTH_INTERVAL | Autofetch interval (in seconds) [default 600 ] |
Force_Default_Prompt | Overwrite the default prompt as well (values 1 /0 ) [default 0 ] |
GIT_SSH_PRIVATE_KEY | Set with path to private key file if different than ~/.ssh/id_rsa , ~/.ssh/id_dsa , ~/.ssh/id_ecdsa , ~/.ssh/id_ecdsa_sk , ~/.ssh/id_ed25519 , or ~/.ssh/id_ed25519_sk . |
Colors can be also customized setting the following parameters with \[ ... \]
-escaped color sequences:
Parameter | Description |
---|---|
User_color | Color of the user field [default Bold Green] |
At_color | Color of the @ symbol [default Purple] |
Host_color | Color of the host field [default Bold Blue] |
Path_color | Color of the path field [default Bold Purple] |
Branch_color | Color of the current branch name [default Green] |
Ahead_color | Color of the commits ahead indicator [default Green] |
Behind_color | Color of the commits behind indicator [default Red] |
NoSync_color | Color of the out-of-sync symbol [default Red] |
Fetch_color | Color of the fetch... message (do not escape with \[...\] ) [default \033[0;32m ] |
Git_color | Color of the git prompt indicator :g~ [default White] |
Prompt_color | Color of the prompt $ [default White] |
Prompt_error_color | Color of the prompt $ when the last command failed [default Bold Red] |
git v1.9.1
Feel free to open a new issue if you find a bug or have feature suggestions.
Thanks!