-
-
Save hraban/84462b53f13b02c491cc22be3c5b0538 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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