Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. ##################################################################
  4. # Setup for colorising your bash prompt
  5. # includes the shell name, current directory, and git branch
  6. # Add this to the end of your `~/.bashrc`
  7. ##################################################################
  8.  
  9. # print the git branch name if in a git project
  10. parse_git_branch() {
  11. git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
  12. }
  13.  
  14. # set the input prompt symbol
  15. ARROW="❯"
  16.  
  17. # define text formatting
  18. PROMPT_BOLD="$(tput bold)"
  19. PROMPT_UNDERLINE="$(tput smul)"
  20. PROMPT_FG_GREEN="$(tput setaf 2)"
  21. PROMPT_FG_CYAN="$(tput setaf 6)"
  22. PROMPT_FG_YELLOW="$(tput setaf 3)"
  23. PROMPT_FG_MAGENTA="$(tput setaf 5)"
  24. PROMPT_RESET="$(tput sgr0)"
  25.  
  26. # save each section prompt section in variable
  27. PROMPT_SECTION_SHELL="\[$PROMPT_BOLD$PROMPT_FG_GREEN\]\s\[$PROMPT_RESET\]"
  28. PROMPT_SECTION_DIRECTORY="\[$PROMPT_UNDERLINE$PROMPT_FG_CYAN\]\W\[$PROMPT_RESET\]"
  29. PROMPT_SECTION_GIT_BRANCH="\[$PROMPT_FG_YELLOW\]\`parse_git_branch\`\[$PROMPT_RESET\]"
  30. PROMPT_SECTION_ARROW="\[$PROMPT_FG_MAGENTA\]$ARROW\[$PROMPT_RESET\]"
  31.  
  32. # set the prompt string using each section variable
  33. PS1="
  34. $PROMPT_SECTION_SHELL $PROMPT_SECTION_DIRECTORY $PROMPT_SECTION_GIT_BRANCH
  35. $PROMPT_SECTION_ARROW "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement