Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 

README.md

git-bashrc

This is a little hack to .bashrc to facilitate the use of GIT through colors to indicate the status of the repository.

preview image

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!

About

A little hack to .bashrc to facilitate the use of GIT

Resources

Releases

No releases published

Packages

No packages published