ygor

.zshrc - Terminal git branch highlighting

Jan 21st, 2021 (edited)
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.37 KB | None | 0 0
  1. # From https://stackoverflow.com/a/58375763/9897863
  2. parse_git_branch() {
  3.     git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
  4. }
  5. COLOR_DEF=$'\e[0m'
  6. COLOR_USR=$'\e[38;5;243m'
  7. COLOR_DIR=$'\e[38;5;197m'
  8. COLOR_GIT=$'\e[38;5;39m'
  9. NEWLINE=$'\n'
  10. setopt PROMPT_SUBST
  11. export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '
Add Comment
Please, Sign In to add comment