Skip to content

Instantly share code, notes, and snippets.

@genki
Last active January 25, 2023 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save genki/d658cb216939ba89f212c7413ede4cd0 to your computer and use it in GitHub Desktop.
Save genki/d658cb216939ba89f212c7413ede4cd0 to your computer and use it in GitHub Desktop.
mr: Move files relatively
#!/usr/bin/ruby
opts, files = ARGV.partition {|a| a =~ /^-/}
first, *middle, last = files
base = File.expand_path File.dirname(first)
to = File.expand_path File.join base, last
system ['mv', *opts, first, *middle, to].join ' '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment