Skip to content

Instantly share code, notes, and snippets.

@meetai
Forked from jnschulze/osx_ramdisk.sh
Last active August 29, 2015 14:15
Show Gist options
  • Save meetai/377df57ecdd3a873a342 to your computer and use it in GitHub Desktop.
Save meetai/377df57ecdd3a873a342 to your computer and use it in GitHub Desktop.
OSX: Move cache folders to RAM
#!/bin/bash
# Size at the end is * 2048 where 2048 = 1 MB, so 1572864 = 768 MB
#DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://1572864`
DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://2097152`
/usr/sbin/diskutil erasevolume HFS+ "RamDiskCache" $DISK
CACHEDIR="/Volumes/RamDiskCache/$USER"
# Chrome Cache
/bin/rm -rvf ~/Library/Caches/Google/Chrome/*
/bin/mkdir -pv $CACHEDIR/Google/Chrome/Default
/bin/ln -v -s $CACHEDIR/Google/Chrome/Default ~/Library/Caches/Google/Chrome/Default
# Firefox Cache
/bin/rm -rvf ~/Library/Caches/Firefox/*
/bin/mkdir -pv $CACHEDIR/Firefox
/bin/ln -v -s $CACHEDIR/Firefox ~/Library/Caches/Firefox  
# Safari Cache
/bin/rm -rvf ~/Library/Caches/com.apple.Safari
/bin/mkdir -pv $CACHEDIR/Apple/Safari
/bin/ln -v -s $CACHEDIR/Apple/Safari ~/Library/Caches/com.apple.Safari
# iTunes Cache
/bin/rm -rvf ~/Library/Caches/com.apple.iTunes
/bin/mkdir -pv $CACHEDIR/Apple/iTunes
/bin/ln -v -s $CACHEDIR/Apple/iTunes ~/Library/Caches/com.apple.iTunes
/usr/bin/chflags hidden /Volumes/RamDiskCache #Hide RamDisk directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment