Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
set -eu -o pipefail
${DEBUGSH+set -x}
# where to store the sparse-image
NAME=civol
SPARSELOC=~/Documents/$NAME.dmg
FSTYPE="APFS"
create() {
hdiutil create -type SPARSEBUNDLE -fs "$FSTYPE" -size 60g -volname "$NAME" "${SPARSELOC}"
attach
}
detach() {
m=$(hdiutil info | grep "/Volumes/$NAME" | cut -f1)
if [ ! -z "$m" ]; then
hdiutil detach $m
fi
}
attach() {
hdiutil attach "${SPARSELOC}.sparsebundle"
}
compact() {
detach
hdiutil compact "${SPARSELOC}" -batteryallowed
attach
}
case "${1-}" in
create) create;;
attach) attach;;
detach) detach;;
compact) compact;;
*)
>&2 echo "Needs an argument: create | attach | detach | compact"
exit 1 ;;
esac
# vim: set sw=4 sts=4 et :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.