A bin folder, holding helpfull scripts and commands
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

giti 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. #
  3. usage="Usage: $0 [-n | no details] [-r | repeat]"
  4. while getopts "hnrs" options; do
  5. case $options in
  6. n ) NO_DETAILS="True";;
  7. r ) REPEAT="True";;
  8. h ) echo $usage
  9. exit 0
  10. ;;
  11. \? ) echo $usage
  12. exit 1
  13. ;;
  14. esac
  15. done
  16. if [[ $REPEAT == "True" ]]; then
  17. watch -n 1 -c "clear && $0 -s"
  18. else
  19. COLOR_WHITE="\033[00m"
  20. COLOR_CYAN="\033[1;36m"
  21. COLOR_RED="\033[1;31m"
  22. COLOR_YELLOW="\033[1;33m"
  23. COLOR_DARKYELLOW="\033[0;33m"
  24. COLOR_GREEN="\033[1;32m"
  25. COLOR_DARKGREEN="\033[0;32m"
  26. COLOR_OCHRE="\033[38;5;95m"
  27. #
  28. git_status="$(LANGUAGE='en_US.UTF-8 git' git status 2> /dev/null)"
  29. git_diff="$(git status --porcelain 2> /dev/null)"
  30. #
  31. if [[ ! $git_status = "" ]]; then
  32. git_branch="$(git branch 2> /dev/null | sed --quiet 's/* \(.*\)/\1/p')"
  33. git_url="$(git config --get remote.origin.url 2> /dev/null)"
  34. if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then
  35. git_status_color="$COLOR_RED"
  36. git_status_text="╡ local changes ╞"
  37. elif [[ $git_status =~ "Your branch is behind" ]]; then
  38. git_status_color="$COLOR_YELLOW"
  39. git_status_text="╡ pull required ╞"
  40. elif [[ $git_status =~ "Your branch is ahead of" ]]; then
  41. git_status_color="$COLOR_YELLOW"
  42. git_status_text="╡ push required ╞"
  43. elif [[ $git_status =~ "nothing to commit" ]]; then
  44. git_status_color="$COLOR_DARKGREEN"
  45. git_status_text="╡ clean ╞════════"
  46. else
  47. git_status_color="$COLOR_OCHRE"
  48. git_status_text="╡ unknown ╞══════"
  49. fi
  50. echo -e "$git_status_color╔═══$git_status_text════════════════════════════════════════════════════════════════"
  51. echo -e "$git_status_color║ $COLOR_GREEN($git_branch) $COLOR_CYAN$git_url"
  52. if [[ ! $git_diff == "" && $NO_DETAILS != "True" ]]; then
  53. echo -e "$git_status_color╠════════════════════════════════════════════════════════════════════════════════════"
  54. IFS=$'\n'
  55. for ENTRY in $git_diff; do
  56. if [[ $ENTRY = "D "* ]] || [[ $ENTRY = "A "* ]] || [[ $ENTRY = "M "* ]] || [[ $ENTRY = "R "* ]]; then
  57. echo -e "$git_status_color║ $COLOR_DARKYELLOW$ENTRY"
  58. else
  59. echo -e "$git_status_color║ $COLOR_YELLOW$ENTRY"
  60. fi
  61. done
  62. fi
  63. echo -e "$git_status_color╚════════════════════════════════════════════════════════════════════════════════════$COLOR_WHITE\n \b"
  64. fi
  65. fi