If you are a Git user, you can find very useful this custom prompt.
Branch
Shows working branch when it detects the current folder is a git one:
user1@labdebian ~/data $
user1@labdebian ~/data $ cd ../myproject/
user1@labdebian ~/myproject (master) $
user1@labdebian ~/myproject (master) $ git checkout -b branch1 Switched to a new branch 'branch1' user1@labdebian ~/myproject (branch1) $ user1@labdebian ~/myproject (branch1) $ git checkout master Switched to branch 'master'
Changes to commit
Exclamation mark when there are changes to commit (working tree clean):
user1@labdebian ~/myproject (master) $
user1@labdebian ~/myproject (master) $ touch file.txt
user1@labdebian ~/myproject (master!) $
The exclamation mark is cleared when all the changes have been committed
user1@labdebian ~/myproject (master!) $ git add .
user1@labdebian ~/myproject (master!) $ git commit -m "Added file.txt"
[master c4e9446] Added file.txt
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file.txt
user1@labdebian ~/myproject (master) $
Code
Add this code to your users ~/.bashrc file, so its loaded when logging:
git_data() {
if [ -d .git ]
then
git status 2> /dev/null | grep "working tree clean" &> /dev/null
if [ $? -ne 0 ]; then STATUS="!"; else STATUS=""; fi
echo -n " (`git branch 2>/dev/null | grep '^*' | colrm 1 2`$STATUS)"
fi
}
export PS1="\u@\h \[\033[36m\]\w\[\033[91m\]\$(git_data) \[\033[00m\]$ "