-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bash_ps
More file actions
41 lines (35 loc) · 1.26 KB
/
.bash_ps
File metadata and controls
41 lines (35 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# This will be main unix/mac startup file
# check if root
# add aliases for PS
# load PS1
# get h/w of window
echo -e "lines\ncols" | tput -S
function git-unpushed {
brinfo=$(git branch -v)
if [[ $brinfo =~ ("[ahead "([[:digit:]]*)]) ]]
then
echo "Not Pushed: ${BASH_REMATCH[2]}"
fi
}
function git-untracked {
untracked=$(git clean --dry-run | wc -l)
if [ $untracked -gt 0 ]
then
echo "Untracked: "$untracked
fi
}
export PS1=$NewLine$BIGreen$user$BIWhite"@"$host" "$BIBlue$PathShort$NewLine$Color_Off" "'$(git branch &>/dev/null;\
if [ $? -eq 0 ]; then \
echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \
if [ "$?" -eq "0" ]; then \
# @4 - Clean repository - nothing to commit
echo $(__git_ps1 " '$IWhite'('$IGreen'%s'$IWhite') '$IYellow'`git-unpushed`"); \
else \
# @5 - Changes to working tree
echo $(__git_ps1 " '$IWhite'('$IYellow'%s'$IWhite') '$IYellow'`git diff --shortstat` '$IRed'`git-untracked`"); \
fi) '$Color_Off' "; \
else \
# @2 - Prompt when not in GIT repo
echo "'"\[\033[1;97m\](\[\033[1;36m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') Items\[\033[1;97m\], \[\033[1;36m\]\$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\033[1;97m\]) \T"$Color_Off' "; \
fi)'"\n "$BIWhite"$: "