Guest User

Untitled

a guest
Dec 10th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. # Colours
  2. export BLUE="\[\033[0;34m\]"
  3. export NO_COLOR="\[\e[0m\]"
  4. export GRAY="\[\033[1;30m\]"
  5. export GREEN="\[\033[0;32m\]"
  6. export LIGHT_GRAY="\[\033[0;37m\]"
  7. export LIGHT_GREEN="\[\033[1;32m\]"
  8. export LIGHT_RED="\[\033[1;31m\]"
  9. export RED="\[\033[0;31m\]"
  10. export WHITE="\[\033[1;37m\]"
  11. export YELLOW="\[\033[0;33m\]"
  12.  
  13. # ls and grep colorize
  14. export GREP_OPTIONS="--color=auto"
  15. export GREP_COLOR="4;33"
  16. export CLICOLOR="auto"
  17. export GEM_EDITOR="mate"
  18.  
  19. alias ls='ls -G'
  20.  
  21. alias textmate_rails="mate app config db features lib public spec Tasks"
  22.  
  23. alias cd_gems="cd ~/Codigos/Ruby/gems/"
  24.  
  25. alias cd_libs="cd ~/Codigos/C/"
  26.  
  27. alias jsonget="curl -X GET -H 'Accept: application/json'"
  28.  
  29. alias start_redis="redis-server /usr/local/etc/redis.conf"
  30.  
  31. alias read_ruby_source_code="mate ~/.rvm/src/ruby-1.9.2-p180/"
  32.  
  33. alias gem_uninstall_all="gem list | cut -d\" \" -f1 | fgrep -v bundler | fgrep -v rake | fgrep -v rdoc | xargs gem uninstall -aIx"
  34.  
  35. alias pull_and_push="git pull origin master && git push origin master"
  36.  
  37. # Set window title
  38. title() {
  39. echo -ne "\033]0;$@\007";
  40. }
  41.  
  42. # list directory after cd; also save the last directory
  43. # and open it when a new tab is created.
  44. cd() {
  45. builtin cd "${@:-$HOME}" && ls && pwd > $CDHISTORY;
  46.  
  47. if [ -f .rvmrc ]; then
  48. __rvm_project_rvmrc
  49. fi
  50. }
  51.  
  52. github() {
  53. if [ $# = 1 ]; then
  54. git clone git@github.com:$USER/$1.git;
  55. builtin cd $1 && ls;
  56. elif [ $# = 2 ]; then
  57. git clone git://github.com/$1/$2.git;
  58. builtin cd $2 && ls;
  59. else
  60. echo "Usage:";
  61. echo " github <repo> ~> will clone $USER's <repo>";
  62. echo " github <user> <repo> ~> will clone <user>'s <repo>";
  63. fi
  64. }
  65.  
  66. custom_prompt () {
  67. local BRANCH=`git branch 2> /dev/null | grep \* | sed 's/* //'`
  68.  
  69. if [[ "$BRANCH" = "" ]]; then
  70. BRANCH=`git status 2> /dev/null | grep "On branch" | sed 's/# On branch //'`
  71. fi
  72.  
  73. local RUBY_VERSION=`ruby -e "puts RUBY_VERSION"`
  74. local GEMSET_NAME=`rvm gemset name`
  75. local RUBY_PROMPT=""
  76. local STATUS=`git status 2>/dev/null`
  77. local PROMPT_COLOR=$GREEN
  78. local STATE=" "
  79. local NOTHING_TO_COMMIT="# Initial commit"
  80. local BEHIND="# Your branch is behind"
  81. local AHEAD="# Your branch is ahead"
  82. local UNTRACKED="# Untracked files"
  83. local DIVERGED="have diverged"
  84. local CHANGED="# Changed but not updated"
  85. local TO_BE_COMMITED="# Changes to be committed"
  86. local LOG=`git log -1 2> /dev/null`
  87.  
  88. if [[ "$GEMSET_NAME" != "" && !($GEMSET_NAME =~ \/Users) ]]; then
  89. RUBY_PROMPT="${RED}(ruby-${RUBY_VERSION}@${GEMSET_NAME})${NO_COLOR} "
  90. else
  91. RUBY_PROMPT="${RED}(ruby-${RUBY_VERSION})${NO_COLOR} "
  92. fi
  93.  
  94. if [ "$STATUS" != "" ]; then
  95. if [[ "$STATUS" =~ "$NOTHING_TO_COMMIT" ]]; then
  96. PROMPT_COLOR=$RED
  97. STATE=""
  98. elif [[ "$STATUS" =~ "$DIVERGED" ]]; then
  99. PROMPT_COLOR=$RED
  100. STATE="${STATE}${RED}↕${NO_COLOR}"
  101. elif [[ "$STATUS" =~ "$BEHIND" ]]; then
  102. PROMPT_COLOR=$RED
  103. STATE="${STATE}${RED}↓${NO_COLOR}"
  104. elif [[ "$STATUS" =~ "$AHEAD" ]]; then
  105. PROMPT_COLOR=$RED
  106. STATE="${STATE}${RED}↑${NO_COLOR}"
  107. elif [[ "$STATUS" =~ "$CHANGED" ]]; then
  108. PROMPT_COLOR=$RED
  109. STATE=""
  110. elif [[ "$STATUS" =~ "$TO_BE_COMMITED" ]]; then
  111. PROMPT_COLOR=$RED
  112. STATE=""
  113. else
  114. PROMPT_COLOR=$GREEN
  115. STATE=""
  116. fi
  117.  
  118. if [[ "$STATUS" =~ "$UNTRACKED" ]]; then
  119. STATE="${STATE}${YELLOW}*${NO_COLOR}"
  120. fi
  121.  
  122. PS1=" ${RUBY_PROMPT}${YELLOW}\w\a${NO_COLOR} (${PROMPT_COLOR}${BRANCH}${NO_COLOR}${STATE}${NO_COLOR})\n⤷ "
  123. else
  124. PS1=" ${RUBY_PROMPT}${YELLOW}\w\a${NO_COLOR}\n⤷ "
  125. fi
  126. }
  127.  
  128. source ~/.git_completion.sh
  129.  
  130. PROMPT_COMMAND=custom_prompt
  131.  
  132. # rvm-install added:
  133. if [[ -s /Users/tomas/.rvm/scripts/rvm ]] ; then source /Users/tomas/.rvm/scripts/rvm ; fi
  134.  
  135. source ~/.profile
Add Comment
Please, Sign In to add comment