Created
October 1, 2019 13:15
-
-
Save clairtonluz/55ca7f08909b273f95454b4c2279babb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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