Skip to content

Instantly share code, notes, and snippets.

@jwhitley
Created October 6, 2011 00:14
Show Gist options
  • Save jwhitley/1266140 to your computer and use it in GitHub Desktop.
Save jwhitley/1266140 to your computer and use it in GitHub Desktop.
#!/bin/zsh
# VOLume Toggle => volt
#
# Usage: volt <volume>
# This script toggles the mountedness of the specified OS X disk
# volume using diskutil. The volume may be specified as the first
# parameter, or as the name of a symlink to this script.
volume=${1:=${0:t}}
mount | grep -q "/Volumes/${volume} *("
if [[ $? -eq 0 ]]; then
# Volume is mounted; eject it
diskutil eject $volume
else
# Volume is unmounted; mount it
diskutil mount $volume
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment