mirror of
https://github.com/cmderdev/cmder.git
synced 2025-06-16 06:37:54 +08:00
Add simple branch name gen for sh and ps1
This commit is contained in:
18
vendor/git-prompt.sh
vendored
18
vendor/git-prompt.sh
vendored
@ -9,6 +9,21 @@ function getGitStatusSetting() {
|
||||
fi
|
||||
}
|
||||
|
||||
function getSimpleGitBranch() {
|
||||
gitDir=$(git rev-parse --git-dir 2>/dev/null)
|
||||
if [ -z "$gitDir" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
headContent=$(< "$gitDir/HEAD")
|
||||
if [[ "$headContent" == "ref: refs/heads/"* ]]
|
||||
then
|
||||
echo " (${headContent:16})"
|
||||
else
|
||||
echo " (HEAD detached at ${headContent:0:7})"
|
||||
fi
|
||||
}
|
||||
|
||||
if test -f /etc/profile.d/git-sdk.sh
|
||||
then
|
||||
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
|
||||
@ -45,6 +60,9 @@ else
|
||||
. "$COMPLETION_PATH/git-prompt.sh"
|
||||
PS1="$PS1"'\[\033[36m\]' # change color to cyan
|
||||
PS1="$PS1"'`__git_ps1`' # bash function
|
||||
else
|
||||
PS1="$PS1"'\[\033[30;1m\]' # change color to gray
|
||||
PS1="$PS1"'`getSimpleGitBranch`'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
Reference in New Issue
Block a user