Skip to content

Instantly share code, notes, and snippets.

@renerdias
Created December 28, 2021 23:08
Show Gist options
  • Save renerdias/90d841cd97947f88d59cfbf7ddbfcd6f to your computer and use it in GitHub Desktop.
Save renerdias/90d841cd97947f88d59cfbf7ddbfcd6f to your computer and use it in GitHub Desktop.
Terminal Config Git
#-------------------------------------------------------------------------------------------------------
#if [ "$color_prompt" = yes ]; then
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
#else
#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
#fi
#unset color_prompt force_color_prompt
# GIT VARIABLES
#-------------------------------------------------------------------------------------------------------
isRepo=0;
numberStashFiles=0;
numberChangeFilesNotCommited=0;
numberCommitNotPushed=0;
numberDeletedFilesNotCommited=0;
branchName=".";
parse_git() {
if [ ! -z $(git rev-parse --git-dir 2> /dev/null) ]; then
isRepo=$((isRepo+1));
#branchName=$(git symbolic-ref --short -q HEAD);
branchName=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/');
# Aparemtemente é excluído + modificado
# numberChangeFilesNotCommited=$(git status --porcelain --untracked-files=no | wc -l);
#numberModifiedFilesNotCommited=
numberChangeFilesNotCommited=$(git ls-files --modified | wc -l 2> /dev/null);
numberCommitNotPushed=$(git cherry -v | wc -l 2> /dev/null);
numberDeletedFilesNotCommited=$(git ls-files --deleted | wc -l 2> /dev/null);
# git diff --name-only --diff-filter=U # conflict list files
#numberStashFiles=$(git stash list | wc -l 2> /dev/null);
#echo "(${branchName}/s${numberStashFiles}/nc${numberChangeFilesNotCommited}/cnp${numberCommitNotPushed})";
echo "(⎇ ${branchName} ✖ ${numberDeletedFilesNotCommited} 🠆 ${numberChangeFilesNotCommited} 🠅 ${numberCommitNotPushed})";
fi
}
#--------------------------------------
# Obtém o nome do branch atual 🛠
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
#currentbranch=$(git symbolic-ref --short -q HEAD)
# FIM - Obtém o nome do branch atual
#--------------------------------------
if [ "$color_prompt" = yes ]; then
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;36m\]$(parse_git_branch)\[\033[00m\] '
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;36m\]$(__git_ps1)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶ \[\033[0m\] '
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;36m\] $(parse_git)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶ \[\033[0m\]'
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\[\033[01;36m\]$(parse_git_branch)\[\033[00m\] '
fi
unset color_prompt force_color_prompt
# --------------------------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment