fish_right_prompt.fish 832 B

1234567891011121314151617181920212223242526272829
  1. function get_git_status -d "Gets the current git status"
  2. if command git rev-parse --is-inside-work-tree >/dev/null 2>&1
  3. set -l dirty (command git status -s --ignore-submodules=dirty | wc -l | sed -e 's/^ *//' -e 's/ *$//' 2> /dev/null)
  4. set -l ref (command git describe --tags --exact-match ^/dev/null ; or command git symbolic-ref --short HEAD 2> /dev/null ; or command git rev-parse --short HEAD 2> /dev/null)
  5. if [ "$dirty" != "0" ]
  6. set_color -b normal
  7. set_color red
  8. echo "$dirty changed file"
  9. if [ "$dirty" != "1" ]
  10. echo "s"
  11. end
  12. echo " "
  13. set_color -b red
  14. set_color white
  15. else
  16. set_color -b cyan
  17. set_color white
  18. end
  19. echo " $ref "
  20. set_color normal
  21. end
  22. end
  23. function fish_right_prompt -d "Prints right prompt"
  24. get_git_status
  25. end