Skip to content

Instantly share code, notes, and snippets.

@AlexSJ
Last active April 17, 2024 22:46
Show Gist options
  • Save AlexSJ/ecd29c258384bdba78cbc85adaab972d to your computer and use it in GitHub Desktop.
Save AlexSJ/ecd29c258384bdba78cbc85adaab972d to your computer and use it in GitHub Desktop.
Exibir nome do git branch no terminal linux
# Abrir o arquivo ~/.bashrc e colar a função a baixo e a variável PS1
# Pode colar no final dele
# Fechar e abrir o terminal ou simplesmente `source ~/.bashrc`
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\]\w\[\033[01;33m\]$(parse_git_branch)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] '
# Opções de cores:
RED="\[\033[01;31m\]"
YELLOW="\[\033[01;33m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
NO_COLOR="\[\033[00m\]"
@AlexSJ
Copy link
Author

AlexSJ commented Apr 17, 2024

Fica assim:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment