Guest User

Untitled

a guest
Jan 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'open3'
  3. include Open3
  4.  
  5. # TODO: use colors in output
  6.  
  7. def gitworld(command)
  8. home = ENV["HOME"]
  9. paths = [ \
  10. "", \
  11. "bin", \
  12. ".vim", \
  13. ".vim/bundle/vim-traitor", \
  14. ".vim/bundle/vimple", \
  15. ".pentadactyl", \
  16. ".oh-my-zsh" \
  17. "sandbox/work", \
  18. "sandbox/personal", \
  19. ]
  20. paths.each do |path|
  21. fullpath = "#{home}/#{path}"
  22. if File.directory? fullpath
  23. Dir.chdir("#{fullpath}")
  24. popen3("git #{command}") do |stdin, stdout, stderr, wait_thr|
  25. output = stdout.read
  26. error = stderr.read
  27. printf "============================[ %30s ]=======\n%s", path, output
  28. puts "" if output.length > 0
  29. print stderr.read
  30. puts "" if error.length > 0
  31. end
  32. end
  33. end
  34. end
  35.  
  36. if ARGV[0].nil?
  37. command = "state"
  38. else
  39. command = ARGV
  40. end
  41.  
  42. puts "Running `git #{command}` on all repositories..."
  43. gitworld command
  44.  
  45. # vim: set ft=ruby
Add Comment
Please, Sign In to add comment