[COLOR=#999988][FONT=Consolas][I]#!/usr/bin/env bash[/I][/FONT][/COLOR]
[COLOR=#999988][I]# cache2ram [/I][/COLOR]
[COLOR=#999988][I]# ---------[/I][/COLOR]
[COLOR=#999988][I]#[/I][/COLOR]
[COLOR=#999988][I]# Copyright (C) 2011 0x46616c6b[/I][/COLOR]
[COLOR=#999988][I]#[/I][/COLOR]
[COLOR=#999988][I]# This program is free software: you can redistribute it and/or modify[/I][/COLOR]
[COLOR=#999988][I]# it under the terms of the GNU General Public License as published by[/I][/COLOR]
[COLOR=#999988][I]# the Free Software Foundation, either version 3 of the License, or[/I][/COLOR]
[COLOR=#999988][I]# (at your option) any later version.[/I][/COLOR]
[COLOR=#999988][I]#[/I][/COLOR]
[COLOR=#999988][I]# This program is distributed in the hope that it will be useful,[/I][/COLOR]
[COLOR=#999988][I]# but WITHOUT ANY WARRANTY; without even the implied warranty of[/I][/COLOR]
[COLOR=#999988][I]# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the[/I][/COLOR]
[COLOR=#999988][I]# GNU General Public License for more details.[/I][/COLOR]
[COLOR=#999988][I]#[/I][/COLOR]
[COLOR=#999988][I]# You should have received a copy of the GNU General Public License[/I][/COLOR]
[COLOR=#999988][I]# along with this program. If not, see <http://www.gnu.org/licenses/>.[/I][/COLOR]
[COLOR=#999988][I]#[/I][/COLOR]
[COLOR=#0086B3]dirs[/COLOR][B]=[/B][COLOR=#DD1144]"Google com.apple.iTunes com.apple.Safari Firefox Chromium"[/COLOR]
[COLOR=teal]size[/COLOR][B]=[/B]1024 [COLOR=#999988][I]# size in mb[/I][/COLOR]
[COLOR=teal]origin[/COLOR][B]=[/B][COLOR=#DD1144]"${HOME}/Library/Caches"[/COLOR]
[COLOR=teal]ramdisk[/COLOR][B]=[/B][COLOR=#DD1144]"/Volumes/ramdisk"[/COLOR]
diskutil erasevolume HFS+ [COLOR=#DD1144]"ramdisk"[/COLOR] [COLOR=#DD1144]`[/COLOR]hdiutil attach -nomount ram://[COLOR=teal]$[[/COLOR]size*2048[B]][/B][COLOR=#DD1144]`[/COLOR]
[B]if[/B] [B][[/B] -d [B]${[/B][COLOR=teal]ramdisk[/COLOR][B]}[/B] [B]][/B]; [B]then[/B]
[B] for [/B]dir in [B]${[/B][COLOR=teal]dirs[/COLOR][B]}[/B]
[B]do[/B]
mkdir [B]${[/B][COLOR=teal]ramdisk[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B]
[B]if[/B] [B][[/B] -d [B]${[/B][COLOR=teal]origin[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B] [B]][/B]; [B]then[/B]
[B] if[/B] [B][[/B] ! -L [B]${[/B][COLOR=teal]origin[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B] [B]][/B]; [B]then[/B]
mv [B]${[/B][COLOR=teal]origin[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B] [B]${[/B][COLOR=teal]origin[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B].bak
[B]fi[/B]
[B] fi[/B]
[B] if[/B] [B][[/B] -L [B]${[/B][COLOR=teal]origin[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B] [B]][/B]; [B]then[/B]
rm [B]${[/B][COLOR=teal]origin[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B]
[B]fi [/B]
[B] if[/B] [B][[/B] ! -L [B]${[/B][COLOR=teal]origin[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B] [B]][/B]; [B]then[/B]
ln -s [B]${[/B][COLOR=teal]ramdisk[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B] [B]${[/B][COLOR=teal]origin[/COLOR][B]}[/B]/[B]${[/B][COLOR=teal]dir[/COLOR][B]}[/B]
[B]fi[/B]
[B] done[/B]
[B]fi[/B]