Skip to content

Instantly share code, notes, and snippets.

@clairtonluz
Created October 1, 2019 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clairtonluz/55ca7f08909b273f95454b4c2279babb to your computer and use it in GitHub Desktop.
Save clairtonluz/55ca7f08909b273f95454b4c2279babb to your computer and use it in GitHub Desktop.
// veja como funciona a sintaxy https://ss64.com/bash/syntax-prompt.html
// veja os valores das colors https://ss64.com/bash/tput.html
// retorna o nome do branch entre [] cochetes
git_branch() {
branchName=$(git branch 2>/dev/null | grep '^*' | colrm 1 2)
if [ ! -z "$branchName" ]; then
echo "[$branchName]"
fi
}
bold=$(tput bold)
userColor=$(tput setaf 6)
pathColor=$(tput setaf 3)
branchColor=$(tput setaf 7)
reset=$(tput sgr0)
export PS1="\$userColor\]\u\[$reset\]@\$userColor\]\h\[$reset\] \$pathColor\]\$bold\]\w\[$reset\] \$branchColor\]\$bold\]\$(git_branch)\[$reset\]\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment