https://github.com/tox82/git-bashrc
A little hack to .bashrc to facilitate the use of GIT
https://github.com/tox82/git-bashrc
Last synced: 5 months ago
JSON representation
A little hack to .bashrc to facilitate the use of GIT
- Host: GitHub
- URL: https://github.com/tox82/git-bashrc
- Owner: ToX82
- Created: 2014-11-25T15:16:26.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-14T13:34:27.000Z (over 11 years ago)
- Last Synced: 2025-02-04T21:19:22.520Z (over 1 year ago)
- Size: 391 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
git-bashrc
==========
This is a little hack to .bashrc to facilitate the use of GIT through colors to indicate the status of the repository.

If you want a shell like that, just add this lines at the end of your .bashrc file:
Color_Off="\[\033[0m\]" # Text Reset
Blue="\[\033[0;94m\]" # Blue
Yellow="\[\033[1;33m\]" # Yellow
Green="\[\033[0;32m\]" # Green
Red="\[\033[0;91m\]" # Red
export PS1='$(
if [ -d .git ]; then
status="$(git status)" > /dev/null 2>&1;
if [[ $status == *"to be committed"* ]]; then
# Changes to be committed
echo "'$Yellow'"$(__git_ps1 " {%s} ") '$Color_Off'\w\$ "";
elif [[ $status == *"Changes not staged"* ]]; then
# Changes to stage
echo "'$Red'"$(__git_ps1 " {%s} ") '$Color_Off'\w\$ "";
elif [[ $status == *"Untracked files:"* ]]; then
# Untracked files
echo "'$Blue'"$(__git_ps1)* '$Color_Off'\w\$ "";
elif [[ $status == *push* ]]; then
# Push needed
echo "'$Green'"$(__git_ps1)* '$Color_Off'\w\$ "";
else
# Clean repository - nothing to commit
echo "'$Green'"$(__git_ps1) '$Color_Off'\w\$ "";
fi
else
# Prompt when not in GIT repo
echo "${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ";
fi
)'
Enjoy!