bashrc-osx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ## Enable color support of ls and also add handy aliases
  2. # Some colors
  3. alias ls='ls -G'
  4. alias grep='grep --color=auto'
  5. # Some utils aliases
  6. alias ll='ls -l'
  7. alias la='ls -A'
  8. alias rmrf='rm -rf'
  9. alias gcl='git clone'
  10. alias vim='vim -p'
  11. # Aliases for executing ~/.script scripts
  12. alias gitan='sh ~/.script/gitan.sh'
  13. alias clean='sh ~/.script/clean.sh'
  14. ## Some export
  15. # colored GCC warnings and errors
  16. export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
  17. # Used for vim header
  18. export VIUSER=xuser
  19. export VIMAIL=xuser@student.42.fr
  20. ## Activate and custom bash completion
  21. #bind 'TAB:menu-complete'
  22. #bind 'set show-all-if-ambiguous on'
  23. ## Setting prompt style
  24. # Get current branch in git repo
  25. function parse_git_branch() {
  26. BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
  27. if [ ! "${BRANCH}" == "" ]
  28. then
  29. STAT=`parse_git_dirty`
  30. echo " [${BRANCH}${STAT}]"
  31. else
  32. echo ""
  33. fi
  34. }
  35. # get current status of git repo
  36. function parse_git_dirty {
  37. status=`git status 2>&1 | tee`
  38. dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
  39. untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
  40. ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
  41. newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
  42. renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
  43. deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
  44. bits=''
  45. if [ "${renamed}" == "0" ] || [ "${newfile}" == "0" ] || [ "${untracked}" == "0" ] || [ "${dirty}" == "0" ]; then
  46. bits="+${bits}"
  47. fi
  48. if [ "${ahead}" == "0" ]; then
  49. bits="*${bits}"
  50. fi
  51. if [ "${deleted}" == "0" ]; then
  52. bits="-${bits}"
  53. fi
  54. if [ ! "${bits}" == "" ]
  55. then
  56. echo " ${bits}"
  57. else
  58. echo ""
  59. fi
  60. }
  61. export PS1='`if [ $? = 0 ]; then echo "\[\033[01;36m\]✔"; else echo "\[\033[01;31m\]✘"; fi` \[\033[32m\]\w\[\033[34m\]$(parse_git_branch " %s") \[\033[0m\]>\[\033[00m\] '
  62. ## Lancement des commandes au demarrages