Skip to content

Instantly share code, notes, and snippets.

@ganey
Forked from dixson3/workspace.sh
Last active January 22, 2019 10:45
Show Gist options
  • Save ganey/8ff96f3bda8754baca760f0805bf914e to your computer and use it in GitHub Desktop.
Save ganey/8ff96f3bda8754baca760f0805bf914e to your computer and use it in GitHub Desktop.
Create and manage a case-sensitive disk-image on OSX. This is great when you have a need to work with case-sensitive repos on a mac.
#!/bin/bash
# where to store the sparse-bundle-image
WORKSPACE=~/Documents/workspace.dmg.sparsebundle
create() {
hdiutil create -type SPARSEBUNDLE -fs 'Case-sensitive APFS - APFS (Case-sensitive)' -size 100g -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