Shell Script Eject All For Quicksilver Trigger

2006 June 19
tags: ,
by nnutter

At Merlin’s request

Rough draft, first attempt, whatever, it doesn’t work quite yet for me but I’ll post it and see if anybody else can help.

Just create a trigger to run the shell script (once it works correctly, it’s close though) and you can eject all with a hot key, no extra apps needed.

Update: I think I got it working, just save this, make it executable with chmod +x and then create a trigger in Quicksilver to run the shell script. (You will need the appropriate Quicksilver plugins. I’ll make a tutorial when I get home probably.)

eject-all.txt

Bugs:

  1. Doesn’t work if volume has spaces.
  2. Doesn’t properly eject disk images, maybe others.
  3. Uses disktool which is deprecated. If I had to I could just use mount but this works.

#!/bin/bash
for i in $( disktool -l | grep "Mountpoint = '/" | sed s/^.*Mountpoint = '// | sed s/',.*// | sed 's/ //g' )
    do
        case "${i}" in
# Add any volumes you might want to skip as alternate case, for example the root volume:
            /)
                ;;
            /Users/nnutter)
                ;;
# This case will take care of all the others, the drives you do want to eject:
            *)
                diskutil eject  "`echo $i | sed 's// /g'`"
                ;;
        esac
    done
Share:
  • Digg
  • E-mail this story to a friend!
  • TwitThis
  • Facebook
  • MySpace
  • Reddit
  • Tumblr
No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS