My Unix config files and shell scripts, optimized for Fedora, Debian, macOS and Windows (in that order).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
997 B

  1. ###
  2. # Common shell functions/aliases between bash and zsh.
  3. ###
  4. # Notify to update the dotfiles.
  5. dfm check-update
  6. ################################################################################
  7. ## Functions
  8. ################################################################################
  9. # Recursively traverse directory tree for git repositories, run git command
  10. # e.g.
  11. # rgit status
  12. # rgit diff
  13. #
  14. # Credit:
  15. # http://chr4.org/blog/2014/09/10/gittree-bash-slash-zsh-function-to-run-git-commands-recursively/
  16. rgit() {
  17. if [ $# -lt 1 ]; then
  18. echo "Usage: rgit <command>"
  19. return 1
  20. fi
  21. for gitdir in $(find . -type d -name .git); do
  22. # Display repository name in bold orange text.
  23. repo=$(dirname $gitdir)
  24. echo -e "\e[1;38;5;208m$repo\e[0m"
  25. # Run git command in the repository's directory
  26. cd $repo && git $@
  27. ret=$?
  28. # Return to calling directory (ignore output)
  29. cd - >/dev/null
  30. # Abort if cd or git command fails
  31. if [ $ret -ne 0 ]; then
  32. return 1
  33. fi
  34. echo
  35. done
  36. }