/bin/git-ls-gsub
https://github.com/banyan/config · Ruby · 16 lines · 9 code · 4 blank · 3 comment · 1 complexity · 6d2bab2563f1dd1e71d0ad1d4a9406a0 MD5 · raw file
- #! /usr/bin/env ruby
- # git ls-gsub <from> <to>
- # git ls-gsub <from> <to> <path>
- from, to, path = ARGV
- if [from, to].include?(nil)
- puts 'from and to must be given: git ls-gsub <from> <to>'
- exit
- end
- target_files = (`git ls-files #{path} | grep #{from}`).each_line.map(&:chomp)
- target_files.each do |file|
- `mv #{file} #{file.gsub from, to}`
- end