-
Notifications
You must be signed in to change notification settings - Fork 0
/
.custom_ps1
32 lines (28 loc) · 1.21 KB
/
.custom_ps1
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
# vi: set ft=sh :
function get_scm_branch {
local git_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(git:\1)/')
if [ -n "$git_branch" ]; then
if [[ -x $(brew --prefix)/bin/git-radar ]]; then
echo -e $($(brew --prefix)/bin/git-radar --bash)
else
echo $git_branch
fi
return 0
fi
local hg_branch=$(hg branch 2> /dev/null | sed -e 's/\(.*\)/(hg:\1)/')
if [ -n "$hg_branch" ]; then
echo $hg_branch
return 0
fi
local _svn_info=$(svn info 2> /dev/null)
if [ -n "$_svn_info" ]; then
local _svn_root=$(echo "$_svn_info" | sed -ne 's#^Repository Root: ##p')
#local _svn_url=$(echo "$_svn_info" | sed -ne 's#^URL: ##p')
#local _svn_branch=$(echo $_svn_url | sed -e 's#^'"$_svn_root"'##g')
local _svn_base=$(basename $_svn_root)
local _svn_rev=$(echo "$_svn_info" | sed -ne '/^Revision: \([0-9]*\).*$/s//\1/p')
echo "(svn:$_svn_base@$_svn_rev)"
return 0
fi
}
PS1='\n$(if [ $? = 0 ]; then echo \[\e[32m\]^_^\[\e[0m\]; else echo \[\e[31m\]O_O\[\e[0m\]; fi) \[\e[01;33m\]\h\[\e[01;34m\] \w \[\e[0;32m\]$(get_scm_branch)\n\[\e[01;34m\]\$\[\e[0m\] '