Guest User

Untitled

a guest
Aug 21st, 2019
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # .bashrc
  2.  
  3. # Source global definitions
  4. if [ -f /etc/bashrc ]; then
  5.     . /etc/bashrc
  6. fi
  7.  
  8. # User specific environment
  9. if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
  10. then
  11.     PATH="$HOME/.local/bin:$HOME/bin:$PATH"
  12. fi
  13. export PATH
  14.  
  15. # Uncomment the following line if you don't like systemctl's auto-paging feature:
  16. # export SYSTEMD_PAGER=
  17.  
  18. # User specific aliases and functions
  19.  
  20. #THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
  21. export SDKMAN_DIR="/home/USRNAME/.sdkman"
  22. [[ -s "/home/USRNAME/.sdkman/bin/sdkman-init.sh" ]] && source "/home/USRNAME/.sdkman/bin/sdkman-init.sh"
  23.  
  24. #Aliases
  25. if [ -f ~/.bash_aliases ]; then
  26.     source ~/.bash_aliases
  27. fi
  28.  
  29. # get current branch in git repo
  30. function parse_git_branch() {
  31.     BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
  32.     if [ ! "${BRANCH}" == "" ]
  33.     then
  34.         STAT=`parse_git_dirty`
  35.         echo "[${BRANCH}${STAT}]"
  36.     else
  37.         echo ""
  38.     fi
  39. }
  40. # get current branch in git repo
  41. function parse_git_branch() {
  42.     BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
  43.     if [ ! "${BRANCH}" == "" ]
  44.     then
  45.         STAT=`parse_git_dirty`
  46.         echo "[${BRANCH}${STAT}]"
  47.     else
  48.         echo ""
  49.     fi
  50. }
  51.  
  52. # get current status of git repo
  53. function parse_git_dirty {
  54.     status=`git status 2>&1 | tee`
  55.     dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
  56.     untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
  57.     ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
  58.     newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
  59.     renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
  60.     deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
  61.     bits=''
  62.     if [ "${renamed}" == "0" ]; then
  63.         bits=">${bits}"
  64.     fi
  65.     if [ "${ahead}" == "0" ]; then
  66.         bits="*${bits}"
  67.     fi
  68.     if [ "${newfile}" == "0" ]; then
  69.         bits="+${bits}"
  70.     fi
  71.     if [ "${untracked}" == "0" ]; then
  72.         bits="?${bits}"
  73.     fi
  74.     if [ "${deleted}" == "0" ]; then
  75.         bits="x${bits}"
  76.     fi
  77.     if [ "${dirty}" == "0" ]; then
  78.         bits="!${bits}"
  79.     fi
  80.     if [ ! "${bits}" == "" ]; then
  81.         echo " ${bits}"
  82.     else
  83.         echo ""
  84.     fi
  85. }
  86.  
  87. export PS1="\[$(tput bold)\]\u@\h:\[$(tput sgr0)\]\[\033[38;5;39m\]\w\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;11m\]\[$(tput bold)\]\`parse_git_branch\`\[\e[m\] \[$(tput sgr0)\]"
RAW Paste Data