Command-line shortcuts to make git easier

g 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/bin/bash
  2. function _status {
  3. echo
  4. echo -e "\e[0;33m> git status\e[0m"
  5. echo
  6. git status
  7. echo
  8. }
  9. function _pull {
  10. echo
  11. echo -e "\e[0;33m> git pull\e[0m"
  12. echo
  13. git pull
  14. echo
  15. }
  16. function _send {
  17. _status
  18. if [ -z "`git status --porcelain`" ]
  19. then
  20. echo -e "\e[0;31m Nothing to commit.\e[0m"
  21. echo
  22. exit
  23. fi
  24. echo -e "\e[0;32m Going to ADD all, COMMIT and PUSH.\e[0m"
  25. echo -e "\e[0;32m Enter commit message (leave blank to abort).\e[0m"
  26. echo
  27. echo -n -e "\e[1;36m [msg]: \e[0m"
  28. read msg
  29. echo
  30. if [ -z "$msg" ]
  31. then
  32. echo -e "\e[0;31m Aborted.\e[0m"
  33. echo
  34. exit
  35. fi
  36. echo -e "\e[0;33m> git add --all\e[0m"
  37. echo
  38. git add --all
  39. echo
  40. echo -e "\e[0;33m> git commit -m \"$msg\"\e[0m"
  41. echo
  42. git commit -m "$msg"
  43. echo
  44. echo -e "\e[0;33m> git push\e[0m"
  45. echo
  46. git push
  47. echo
  48. }
  49. function _stage {
  50. _status
  51. if [ -z "`git status --porcelain`" ]
  52. then
  53. echo -e "\e[0;31m Nothing to commit.\e[0m"
  54. echo
  55. exit
  56. fi
  57. echo -e "\e[0;32m Going to ADD all and COMMIT.\e[0m"
  58. echo -e "\e[0;32m Enter commit message (leave blank to abort).\e[0m"
  59. echo
  60. echo -n -e "\e[1;36m [msg]: \e[0m"
  61. read msg
  62. echo
  63. if [ -z "$msg" ]
  64. then
  65. echo -e "\e[0;31m Aborted.\e[0m"
  66. echo
  67. exit
  68. fi
  69. echo -e "\e[0;33m> git add --all\e[0m"
  70. echo
  71. git add --all
  72. echo
  73. echo -e "\e[0;33m> git commit -m \"$msg\"\e[0m"
  74. echo
  75. git commit -m "$msg"
  76. echo
  77. }
  78. case $1 in
  79. "check" | "status")
  80. _status
  81. ;;
  82. "pull")
  83. _pull
  84. ;;
  85. "send")
  86. _send
  87. ;;
  88. "push")
  89. echo -e "\e[0;33m> git push\e[0m"
  90. echo
  91. git push
  92. echo
  93. ;;
  94. "stage" | "commit" | "add")
  95. _stage
  96. ;;
  97. *)
  98. echo -e "\n\e[0;31m Invalid ACTION '$1', use one of {check/status, pull, send, push, stage/commit} !\e[0m\n";
  99. ;;
  100. esac