inspiration from __git_ps1

This reverts commit c17290e75d.
This commit is contained in:
Felix Van der Jeugt 2017-08-02 10:01:26 +02:00
parent c17290e75d
commit 41b49397d1
No known key found for this signature in database
GPG Key ID: 58B209295023754D

17
bashrc
View File

@ -1,6 +1,15 @@
# 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 rev-list --left-only --count @{upstream}...HEAD | sed -n 's/[^0].*/⇃&/p' ; }
prompt_gbefore() { git rev-list --right-only --count @{upstream}...HEAD | sed -n 's/[^0].*/↿&/p' ; }
prompt_gstatus() { git status --porcelain | sed 's/\(..\).*/\1/' | cat <(echo OK) - | tail -1 ; }
prompt_git() {
if git status 2>/dev/null 1>&2; then
echo " ($(prompt_gbranch)$(prompt_gbehind)$(prompt_gbefore) $(prompt_gstatus))"
fi
}
prompt_pwd() { prompt_pwd() {
pwd | sed -e "s_${HOME}_~_" -e 's_\(/*.\)[^/]*/_\1/_g' pwd | sed -e "s_${HOME}_~_" -e 's_\(/*.\)[^/]*/_\1/_g'
} }
@ -13,12 +22,7 @@ prompt_status() {
BOLD="\[$(tput bold)\]" BOLD="\[$(tput bold)\]"
GREEN="\[$(tput setaf 2)\]" GREEN="\[$(tput setaf 2)\]"
RESET="\[$(tput sgr0)\]" RESET="\[$(tput sgr0)\]"
source /usr/share/git/git-prompt.sh PS1="$BOLD[\T]$RESET $GREEN\$(ks prompt_pwd)$RESET\$(ks prompt_git)\$(prompt_status) "
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="auto verbose"
PROMPT_COMMAND="__git_ps1 \"$BOLD[\T]$RESET $GREEN\$(ks prompt_pwd)$RESET\" \"\$(prompt_status) \""
unset BOLD unset BOLD
unset GREEN unset GREEN
unset RESET unset RESET
@ -26,7 +30,6 @@ unset RESET
# Completion # Completion
complete -c man complete -c man
complete -cf sudo complete -cf sudo
complete -cf exec
# Color ls # Color ls
alias ls="lr -1FG" alias ls="lr -1FG"