Skip to content

Instantly share code, notes, and snippets.

@rjungemann
Created September 3, 2010 16:30
Show Gist options
  • Save rjungemann/564134 to your computer and use it in GitHub Desktop.
Save rjungemann/564134 to your computer and use it in GitHub Desktop.
Script to mount a filesystem with MacFUSE, then copy its address to the clipboard
#!/usr/bin/env ruby
# simply copy an ip address to your clipboard, then run:
# ./drivel.rb
# to mount an sshfs partition and open it up in Finder.app. To unmount, run:
# ./drivel.rb unmount
# requires a Mac running MacFUSE and sshfs
host = `pbpaste`
prefix = host.include?("@") ? "@" : ""
suffix = host.include?(":") ? ":" : ""
dirname = host.match("#{prefix}(.+)#{suffix}")[1]
suffixed_host = host.include?(":") ? host : "#{host}:"
puts "creating #{host} at the directory #{dirname}"
if ARGV.first == "unmount"
`cd /Volumes && umount #{dirname} && rm -rf #{dirname}`
else
`cd /Volumes && mkdir #{dirname} && \
sshfs #{suffixed_host} #{dirname} && open #{dirname}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment