1
0
mirror of https://github.com/meineerde/dotfiles.git synced 2025-10-17 19:41:01 +00:00

Further simplify prompt_vcs

This commit is contained in:
Holger Just 2025-01-21 00:57:17 +01:00
parent 05cb36709a
commit dc43aa9130

23
.bashrc
View File

@ -280,31 +280,20 @@ esac
ps1_host='\h'
__prompt_vcs() {
if [[ -z $NOPROMPT ]]; then
local vcs base_dir ref base_dir
git_dir() {
if [[ -z "$NOPROMPT" ]]; then
git_ref() {
ref=$(echo -e "$(__git_ps1 "(%s)")")
if [ -z "$ref" ]; then return 1; fi
vcs="git"
echo "$ref"
}
svn_dir() {
svn_ref() {
[ -d ".svn" ] || return 1
ref=$(svn info | awk '/^URL/ { sub(".*/","",$0); r=$0 } /^Revision/ { sub("[^0-9]*","",$0); print $0 }')
ref="[$ref]"
vcs="svn"
echo "[$ref]"
}
git_dir || svn_dir
if [ -n "$vcs" ]; then
alias st="$vcs status"
alias d="$vcs diff"
__vcs_ref="$ref"
echo " $__vcs_ref"
fi
git_ref || svn_ref
fi
}
ps1_vcs='$(__prompt_vcs)'