Skip to content

Instantly share code, notes, and snippets.

@wisq
Created August 3, 2010 16:26
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 wisq/506677 to your computer and use it in GitHub Desktop.
Save wisq/506677 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'pathname'
file, project = ARGV.take(2).collect do |p|
if p.empty?
nil
else
Pathname.new(p)
end
end
if file.nil?
puts "Usage: #{$0} file [path]"
exit(1)
end
IO.popen('pbcopy', 'w') do |fh|
if project
rel = file.relative_path_from(project)
fh.print rel
puts "Relative path: #{rel}"
else
fh.print file
puts "Full path: #{file}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment