Skip to content

Instantly share code, notes, and snippets.

@x2c3z4
Forked from dixson3/workspace.sh
Last active August 29, 2015 14:14
Show Gist options
  • Save x2c3z4/a827ff478b1968f3b8d4 to your computer and use it in GitHub Desktop.
Save x2c3z4/a827ff478b1968f3b8d4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# where to store the sparse-image
WORKSPACE=~/Documents/workspace.dmg.sparseimage
create() {
hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 60g -volname workspace ${WORKSPACE}
}
detach() {
m=$(hdiutil info | grep "/Volumes/workspace" | cut -f1)
if [ ! -z "$m" ]; then
hdiutil detach $m
fi
}
attach() {
hdiutil attach ${WORKSPACE}
}
compact() {
detach
hdiutil compact ${WORKSPACE} -batteryallowed
attach
}
case "$1" in
create) create;;
attach) attach;;
detach) detach;;
compact) compact;;
*) ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment