take back contributions from r13n
This commit is contained in:
parent
b157ae0c3b
commit
c68327a366
17
bashrc
17
bashrc
@ -1,13 +1,14 @@
|
|||||||
|
|
||||||
# Get ourselves a nice prompt
|
# Get ourselves a nice prompt
|
||||||
ks() { s="$?" ; $* ; return "$s" ; }
|
ks() { s="$?" ; $* ; return "$s" ; }
|
||||||
prompt_gbranch() { git branch | sed -n 's/^\* (*\(.* \)*\([^ )]*\))*$/\2/p' ; }
|
|
||||||
prompt_gbehind() { git status --branch --porcelain=2 | sed -n 's/^# branch\.ab.*-\([^0].*\)$/⇃\1/p' ; }
|
|
||||||
prompt_gbefore() { git status --branch --porcelain=2 | sed -n 's/^# branch\.ab +\([^0].*\) .*$/↿\1/p' ; }
|
|
||||||
prompt_gstatus() { git status --porcelain | sed 's/\(..\).*/\1/' | cat <(echo OK) - | tail -1 ; }
|
|
||||||
prompt_git() {
|
prompt_git() {
|
||||||
if git status 2>/dev/null 1>&2; then
|
if git status 2>/dev/null 1>&2; then
|
||||||
echo " ($(prompt_gbranch)$(prompt_gbehind)$(prompt_gbefore)|$(prompt_gstatus))"
|
local branch="$(git branch | sed -n 's/^\* (*\(.* \)*\([^ )]*\))*$/\2/p')"
|
||||||
|
local behind="$(git status --branch --porcelain=2 | sed -n 's/^# branch\.ab.*-\([^0].*\)$/⇃\1/p')"
|
||||||
|
local before="$(git status --branch --porcelain=2 | sed -n 's/^# branch\.ab +\([^0].*\) .*$/↿\1/p')"
|
||||||
|
local status="$(git status --porcelain | sed 's/\(..\).*/\1/' | cat <(echo OK) - | tail -1)"
|
||||||
|
|
||||||
|
echo " (${branch}${behind}${before}|${status})"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
prompt_pwd() {
|
prompt_pwd() {
|
||||||
@ -19,9 +20,9 @@ prompt_status() {
|
|||||||
else echo "%"
|
else echo "%"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
BOLD="\[$(tput bold)\]"
|
BOLD="\001$(tput bold)\002"
|
||||||
GREEN="\[$(tput setaf 2)\]"
|
GREEN="\001$(tput setaf 2)\002"
|
||||||
RESET="\[$(tput sgr0)\]"
|
RESET="\001$(tput sgr0)\002"
|
||||||
PS1="$BOLD[\T]$RESET $GREEN\$(ks prompt_pwd)$RESET\$(ks prompt_git) \$(prompt_status) "
|
PS1="$BOLD[\T]$RESET $GREEN\$(ks prompt_pwd)$RESET\$(ks prompt_git) \$(prompt_status) "
|
||||||
unset BOLD
|
unset BOLD
|
||||||
unset GREEN
|
unset GREEN
|
||||||
|
Loading…
Reference in New Issue
Block a user