diff --git a/Contents/MacOS/apps/android-studio b/Contents/MacOS/apps/android-studio new file mode 100644 index 0000000..d5314e3 --- /dev/null +++ b/Contents/MacOS/apps/android-studio @@ -0,0 +1,20 @@ +#!/usr/bin/env bash -x + +# +# Android Studio +# +app_name="Android Studio" + +move_android_studio_cache() +{ + close_app "Android Studio" + echo "moving Android Studio cache"; + if [ -d "/Applications/Android Studio.app" ]; then + # make a backup of config - will need it when uninstalling + cp -f /Applications/Android\ Studio.app/Contents/bin/idea.properties /Applications/Android\ Studio.app/Contents/bin/idea.properties.back + # Idea will create those dirs + echo "idea.system.path=${USERRAMDISK}/AndroidStudio" >> /Applications/Android\ Studio.app/Contents/bin/idea.properties + echo "idea.log.path=${USERRAMDISK}/AndroidStudio/logs" >> /Applications/Android\ Studio.app/Contents/bin/idea.properties + echo "Moved Android cache." + fi +} diff --git a/Contents/MacOS/apps/appcode b/Contents/MacOS/apps/appcode new file mode 100644 index 0000000..a6b6d62 --- /dev/null +++ b/Contents/MacOS/apps/appcode @@ -0,0 +1,22 @@ +# +# AppCode +# + +app_name="AppCode" + +move_appcode_cache() +{ + if [ -d "/Applications/AppCode.app" ]; then + if user_response "I found AppCode. Do you want me to move its cache?" ; then + echo "moving AppCode cache"; + close_app "AppCode" + # make a backup of config - will need it when uninstalling + cp -f /Applications/AppCode.app/Contents/bin/idea.properties /Applications/AppCode.app/Contents/bin/idea.properties.back + # Need to create those dirs + echo "idea.system.path=${USERRAMDISK}/AppCode" >> /Applications/AppCode.app/Contents/bin/idea.properties + echo "idea.log.path=${USERRAMDISK}/AppCode/logs" >> /Applications/AppCode.app/Contents/bin/idea.properties + mkdir -p ${USERRAMDISK}/AppCode/logs + echo "Moved AppCode cache." + fi + fi +} diff --git a/Contents/MacOS/apps/chrome-canary b/Contents/MacOS/apps/chrome-canary new file mode 100644 index 0000000..ad322ef --- /dev/null +++ b/Contents/MacOS/apps/chrome-canary @@ -0,0 +1,15 @@ + + +app_name="Chrome Canary" + +move_chrome_chanary_cache() +{ + if [ -d "/Users/${USER}/Library/Caches/Google/Chrome Canary" ]; then + if user_response "I found Chrome Canary. Do you want move its cache?"; then + close_app "Chrome Canary" + /bin/rm -rf ~/Library/Caches/Google/Chrome\ Canary/* + /bin/mkdir -p ${USERRAMDISK}/Google/Chrome\ Canary/Default + /bin/ln -s ${USERRAMDISK}/Google/Chrome\ Canary/Default ~/Library/Caches/Google/Chrome\ Canary/Default + fi + fi +} diff --git a/Contents/MacOS/apps/clion b/Contents/MacOS/apps/clion new file mode 100644 index 0000000..a02996b --- /dev/null +++ b/Contents/MacOS/apps/clion @@ -0,0 +1,21 @@ +# +# Clion +# + +app_name="Clion" + +move_clion_cache() +{ + if [ -d "/Applications/Clion.app" ]; then + if user_response "I found CLion. Do you want me to move its cache?" ; then + echo "moving Clion cache"; + close_app "Clion" + # make a backup of config - will need it when uninstalling + cp -f /Applications/Clion.app/Contents/bin/idea.properties /Applications/Clion.app/Contents/bin/idea.properties.back + # Idea will create those dirs + echo "idea.system.path=${USERRAMDISK}/CLion" >> /Applications/Clion.app/Contents/bin/idea.properties + echo "idea.log.path=${USERRAMDISK}/Clion/logs" >> /Applications/Clion.app/Contents/bin/idea.properties + echo "Moved Clion cache." + fi + fi +} diff --git a/Contents/MacOS/apps/google-chrome b/Contents/MacOS/apps/google-chrome new file mode 100644 index 0000000..5881fbc --- /dev/null +++ b/Contents/MacOS/apps/google-chrome @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# +# Google Chrome Cache +# + +app_name="Google Chrome" + +move_chrome_cache() +{ + if [ -d "/Users/${USER}/Library/Caches/Google/Chrome" ]; then + if user_response "I found chrome. Do you want me to move its cache?" ; then + close_app "Google Chrome" + /bin/mkdir -p /tmp/Google/Chrome + /bin/mv ~/Library/Caches/Google/Chrome/* /tmp/Google/Chrome/ + /bin/mkdir -pv ${USERRAMDISK}/Google/Chrome/Default + /bin/mv /tmp/Google/Chrome/ ${USERRAMDISK}/Google/Chrome + /bin/ln -v -s -f ${USERRAMDISK}/Google/Chrome/Default ~/Library/Caches/Google/Chrome/Default + /bin/rm -rf /tmp/Google/Chrome + # and let's create a flag for next run that we moved the cache. + echo ""; + fi + else + echo "No Google chrome folder has been found. Skiping." + fi +} diff --git a/Contents/MacOS/apps/intellij-14 b/Contents/MacOS/apps/intellij-14 new file mode 100644 index 0000000..0bd6891 --- /dev/null +++ b/Contents/MacOS/apps/intellij-14 @@ -0,0 +1,15 @@ + +app_name="IntelliJ Idea 14" + +move_idea_cache() +{ + if [ -d "/Applications/IntelliJ IDEA 14.app" ]; then + close_app "IntelliJ Idea 14" + # make a backup of config - will need it when uninstalling + cp -f /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties.back + # Idea will create those dirs + echo "idea.system.path=${USERRAMDISK}/Idea" >> /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties + echo "idea.log.path=${USERRAMDISK}/Idea/logs" >> /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties + echo "Moved IntelliJ cache." + fi +} diff --git a/Contents/MacOS/apps/intellij-15 b/Contents/MacOS/apps/intellij-15 new file mode 100644 index 0000000..d50ad21 --- /dev/null +++ b/Contents/MacOS/apps/intellij-15 @@ -0,0 +1,15 @@ + +app_name="IntelliJ Idea 15" + +move_idea_cache() +{ + if [ -d "/Applications/IntelliJ IDEA 15.app" ]; then + close_app "IntelliJ Idea 15" + # make a backup of config - will need it when uninstalling + cp -f /Applications/IntelliJ\ IDEA\ 15.app/Contents/bin/idea.properties /Applications/IntelliJ\ IDEA\ 15.app/Contents/bin/idea.properties.back + # Idea will create those dirs + echo "idea.system.path=${USERRAMDISK}/Idea" >> /Applications/IntelliJ\ IDEA\ 15.app/Contents/bin/idea.properties + echo "idea.log.path=${USERRAMDISK}/Idea/logs" >> /Applications/IntelliJ\ IDEA\ 15.app/Contents/bin/idea.properties + echo "Moved IntelliJ cache." + fi +} diff --git a/Contents/MacOS/apps/intellij-idea-ce-14 b/Contents/MacOS/apps/intellij-idea-ce-14 new file mode 100644 index 0000000..605ad9a --- /dev/null +++ b/Contents/MacOS/apps/intellij-idea-ce-14 @@ -0,0 +1,17 @@ + + +app_name="IntelliJ Idea 14 CE" + + +move_ideace_cache() +{ + if [ -d "/Applications/IntelliJ IDEA 14 CE.app" ]; then + close_app "IntelliJ Idea 14 CE" + # make a backup of config - will need it when uninstalling + cp -f /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/bin/idea.properties /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/bin/idea.properties.back + # Idea will create those dirs + echo "idea.system.path=${USERRAMDISK}/Idea" >> /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/bin/idea.properties + echo "idea.log.path=${USERRAMDISK}/Idea/logs" >> /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/bin/idea.properties + echo "Moved IntelliJ cache." + fi +} diff --git a/Contents/MacOS/apps/itunes b/Contents/MacOS/apps/itunes new file mode 100644 index 0000000..61f0269 --- /dev/null +++ b/Contents/MacOS/apps/itunes @@ -0,0 +1,13 @@ + +app_name="iTunes" + +move_itunes_cache() +{ + if [ -d "/Users/${USER}/Library/Caches/com.apple.iTunes" ]; then + close_app "iTunes" + /bin/rm -rf /Users/${USER}/Library/Caches/com.apple.iTunes + /bin/mkdir -pv ${USERRAMDISK}/Apple/iTunes + /bin/ln -v -s ${USERRAMDISK}/Apple/iTunes ~/Library/Caches/com.apple.iTunes + echo "Moved iTunes cache." + fi +} diff --git a/Contents/MacOS/apps/safari b/Contents/MacOS/apps/safari new file mode 100644 index 0000000..7060c44 --- /dev/null +++ b/Contents/MacOS/apps/safari @@ -0,0 +1,15 @@ + +app_name="iTunes" + +move_safari_cache() +{ + if [ -d "/Users/${USER}/Library/Caches/com.apple.Safari" ]; then + if user_response "Do you want to move Safari cache?"; then + close_app "Safari" + /bin/rm -rf ~/Library/Caches/com.apple.Safari + /bin/mkdir -p ${USERRAMDISK}/Apple/Safari + /bin/ln -s ${USERRAMDISK}/Apple/Safari ~/Library/Caches/com.apple.Safari + echo "Moved Safari cache." + fi + fi +} diff --git a/Contents/MacOS/apps/template_app b/Contents/MacOS/apps/template_app new file mode 100644 index 0000000..d1a1226 --- /dev/null +++ b/Contents/MacOS/apps/template_app @@ -0,0 +1,13 @@ +#!/usr/bin/env bash -x + +# +# name of the app goes here +# +name_of_function_to_move_app_cache() +{ + close_app "app name" + echo "moving app name cache"; + # do whatever you need to do to move the caches and add cron jobs with rsync etc + echo "Moved app name cache." + fi +} diff --git a/Contents/MacOS/startupRAMDiskandCacheMover.sh b/Contents/MacOS/startupRAMDiskandCacheMover.sh index af2725f..6816fc4 100755 --- a/Contents/MacOS/startupRAMDiskandCacheMover.sh +++ b/Contents/MacOS/startupRAMDiskandCacheMover.sh @@ -1,6 +1,5 @@ -#!/usr/bin/env bash -x +#!/usr/bin/env bash -xa -# # Copyright Zafar Khaydarov # # This is about to create a RAM disk in OS X and move the apps caches into it @@ -25,7 +24,7 @@ mount_point=/Volumes/ramdisk ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512)) ramdisk_device=`hdid -nomount ram://${ramfs_size_sectors}` USERRAMDISK="$mount_point/${USER}" - +script_folder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # # Checks for the user response. # @@ -129,7 +128,7 @@ check_for_flag() # make_flag() { - echo "" > /Applications/OSX-RAMDisk.app/${1} + echo "" > ${script_folder}/settings/${1} } # ------------------------------------------------------ @@ -137,200 +136,58 @@ make_flag() # Add yours at the end. # ------------------------------------------------------- +apps=./apps/* +for f in ${apps}; do + source ${f} # todo get the file name only + if user_response "I found ${app_name}, would you keep it's cache in RAM?" ; then + make_flag ${f} + fi +done + # # Google Chrome Cache # -move_chrome_cache() -{ - if [ -d "/Users/${USER}/Library/Caches/Google/Chrome" ]; then - if user_response "I found chrome. Do you want me to move its cache?" ; then - close_app "Google Chrome" - /bin/mkdir -p /tmp/Google/Chrome - /bin/mv ~/Library/Caches/Google/Chrome/* /tmp/Google/Chrome/ - /bin/mkdir -pv ${USERRAMDISK}/Google/Chrome/Default - /bin/mv /tmp/Google/Chrome/ ${USERRAMDISK}/Google/Chrome - /bin/ln -v -s -f ${USERRAMDISK}/Google/Chrome/Default ~/Library/Caches/Google/Chrome/Default - /bin/rm -rf /tmp/Google/Chrome - # and let's create a flag for next run that we moved the cache. - echo ""; - fi - else - echo "No Google chrome folder has been found. Skipping." - fi -} +. apps/google-chrome # # Chrome Canary Cache # -move_chrome_chanary_cache() -{ - if [ -d "/Users/${USER}/Library/Caches/Google/Chrome Canary" ]; then - if user_response "I found Chrome Canary. Do you want move its cache?"; then - close_app "Chrome Canary" - /bin/rm -rf ~/Library/Caches/Google/Chrome\ Canary/* - /bin/mkdir -p ${USERRAMDISK}/Google/Chrome\ Canary/Default - /bin/ln -s ${USERRAMDISK}/Google/Chrome\ Canary/Default ~/Library/Caches/Google/Chrome\ Canary/Default - fi - fi -} +. apps/chrome-canary # # Safari Cache # -move_safari_cache() -{ - if [ -d "/Users/${USER}/Library/Caches/com.apple.Safari" ]; then - if user_response "Do you want to move Safari cache?"; then - close_app "Safari" - /bin/rm -rf ~/Library/Caches/com.apple.Safari - /bin/mkdir -p ${USERRAMDISK}/Apple/Safari - /bin/ln -s ${USERRAMDISK}/Apple/Safari ~/Library/Caches/com.apple.Safari - echo "Moved Safari cache." - fi - fi -} +. /apps/safari # # iTunes Cache # -move_itunes_cache() -{ - if [ -d "/Users/${USER}/Library/Caches/com.apple.iTunes" ]; then - close_app "iTunes" - /bin/rm -rf /Users/${USER}/Library/Caches/com.apple.iTunes - /bin/mkdir -pv ${USERRAMDISK}/Apple/iTunes - /bin/ln -v -s ${USERRAMDISK}/Apple/iTunes ~/Library/Caches/com.apple.iTunes - echo "Moved iTunes cache." - fi -} +. /apps/itunes # # Intellij Idea # -# fixme - what if the version is not 14? -move_idea_cache() -{ - if [ -d "/Applications/IntelliJ IDEA 14.app" ]; then - if user_response "I found IntelliJ IDEA 14. Do you want me to move its cache?" ; then - close_app "IntelliJ Idea 14" - # make a backup of config - will need it when uninstalling - cp -f /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties.back - # Idea will create those dirs - echo "idea.system.path=${USERRAMDISK}/Idea" >> /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties - echo "idea.log.path=${USERRAMDISK}/Idea/logs" >> /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties - echo "Moved IntelliJ cache." - fi - fi - - - if [ -d "/Applications/IntelliJ IDEA 15.app" ]; then - if user_response "I found IntelliJ IDEA 15. Do you want me to move its cache?" ; then - close_app "IntelliJ Idea 15" - # make a backup of config - will need it when uninstalling - cp -f /Applications/IntelliJ\ IDEA\ 15.app/Contents/bin/idea.properties /Applications/IntelliJ\ IDEA\ 15.app/Contents/bin/idea.properties.back - # Idea will create those dirs - echo "idea.system.path=${USERRAMDISK}/Idea" >> /Applications/IntelliJ\ IDEA\ 15.app/Contents/bin/idea.properties - echo "idea.log.path=${USERRAMDISK}/Idea/logs" >> /Applications/IntelliJ\ IDEA\ 15.app/Contents/bin/idea.properties - echo "Moved IntelliJ 15 cache." - fi - fi -} +. /apps/intellij-14 # # Intellij Idea Community Edition # -move_ideace_cache() -{ - # todo add other versions support and CE edition - if [ -d "/Applications/IntelliJ IDEA 14 CE.app" ]; then - if user_response "I found IntelliJ IDEA CE 14. Do you want me to move its cache?" ; then - close_app "IntelliJ Idea 14 CE" - # make a backup of config - will need it when uninstalling - cp -f /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/bin/idea.properties /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/bin/idea.properties.back - # Idea will create those dirs - echo "idea.system.path=${USERRAMDISK}/Idea" >> /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/bin/idea.properties - echo "idea.log.path=${USERRAMDISK}/Idea/logs" >> /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/bin/idea.properties - echo "Moved IntelliJ cache." - fi - fi - - if [ -d "/Applications/IntelliJ IDEA 15 CE.app" ]; then - if user_response "I found IntelliJ IDEA CE 15. Do you want me to move its cache?" ; then - close_app "IntelliJ Idea 14 CE" - # make a backup of config - will need it when uninstalling - cp -f /Applications/IntelliJ\ IDEA\ 15\ CE.app/Contents/bin/idea.properties /Applications/IntelliJ\ IDEA\ 15\ CE.app/Contents/bin/idea.properties.back - # Idea will create those dirs - echo "idea.system.path=${USERRAMDISK}/Idea" >> /Applications/IntelliJ\ IDEA\ 15\ CE.app/Contents/bin/idea.properties - echo "idea.log.path=${USERRAMDISK}/Idea/logs" >> /Applications/IntelliJ\ IDEA\ 15\ CE.app/Contents/bin/idea.properties - echo "Moved IntelliJ cache." - fi - fi -} - -# -# Creates intelliJ intermediate output folder -# to be used by java/scala projects. -# -create_intermediate_folder_for_intellij_projects() -{ - [ -d /Volumes/ramdisk/${USER}/compileroutput ] || mkdir -p /Volumes/ramdisk/${USER}/compileroutput -} +. apps/intellij-idea-ce-14 # # Android Studio # -move_android_studio_cache() -{ - close_app "Android Studio" - echo "moving Android Studio cache"; - if [ -d "/Applications/Android Studio.app" ]; then - # make a backup of config - will need it when uninstalling - cp -f /Applications/Android\ Studio.app/Contents/bin/idea.properties /Applications/Android\ Studio.app/Contents/bin/idea.properties.back - # Idea will create those dirs - echo "idea.system.path=${USERRAMDISK}/AndroidStudio" >> /Applications/Android\ Studio.app/Contents/bin/idea.properties - echo "idea.log.path=${USERRAMDISK}/AndroidStudio/logs" >> /Applications/Android\ Studio.app/Contents/bin/idea.properties - echo "Moved Android cache." - fi -} +. /apps/android-studio # # Clion # -move_clion_cache() -{ - if [ -d "/Applications/Clion.app" ]; then - if user_response "I found CLion. Do you want me to move its cache?" ; then - echo "moving Clion cache"; - close_app "Clion" - # make a backup of config - will need it when uninstalling - cp -f /Applications/Clion.app/Contents/bin/idea.properties /Applications/Clion.app/Contents/bin/idea.properties.back - # Idea will create those dirs - echo "idea.system.path=${USERRAMDISK}/CLion" >> /Applications/Clion.app/Contents/bin/idea.properties - echo "idea.log.path=${USERRAMDISK}/Clion/logs" >> /Applications/Clion.app/Contents/bin/idea.properties - echo "Moved Clion cache." - fi - fi -} +. /apps/clion # # AppCode # -move_appcode_cache() -{ - if [ -d "/Applications/AppCode.app" ]; then - if user_response "I found AppCode. Do you want me to move its cache?" ; then - echo "moving AppCode cache"; - close_app "AppCode" - # make a backup of config - will need it when uninstalling - cp -f /Applications/AppCode.app/Contents/bin/idea.properties /Applications/AppCode.app/Contents/bin/idea.properties.back - # Need to create those dirs - echo "idea.system.path=${USERRAMDISK}/AppCode" >> /Applications/AppCode.app/Contents/bin/idea.properties - echo "idea.log.path=${USERRAMDISK}/AppCode/logs" >> /Applications/AppCode.app/Contents/bin/idea.properties - mkdir -p ${USERRAMDISK}/AppCode/logs - echo "Moved AppCode cache." - fi - fi -} +. /apps/appcode # ----------------------------------------------------------------------------------- @@ -345,13 +202,10 @@ main() { move_safari_cache move_idea_cache move_ideace_cache - # create intermediate folder for intellij projects output - create_intermediate_folder_for_intellij_projects move_itunes_cache move_android_studio_cache move_clion_cache move_appcode_cache - echo "echo use \"/Volumes/ramdisk/${USER}/compileroutput\" for intelliJ project output directory." echo "All good - I have done my job. Your apps should fly." } diff --git a/homebrew-osx-ramdisk/Formula/osx-ramdisk.rb b/homebrew-osx-ramdisk/Formula/osx-ramdisk.rb new file mode 100644 index 0000000..5f3809c --- /dev/null +++ b/homebrew-osx-ramdisk/Formula/osx-ramdisk.rb @@ -0,0 +1,19 @@ +class ramdisk < Formula + desc "Creates ram-disk making browsers and IDEs fly." + homepage "http://zafarella.github.io/OSX-RAMDisk/" + url "https://github.com/zafarella/OSX-RAMDisk/tarball/master" + sha256 "" + head "https://github.com/zafarella/OSX-RAMDisk.git" + version "1.0" + + depends_on "newfs_hfs" + + def install + system "Contents/MacOS/startupRAMDiskandCacheMover.sh" + end + + test do + system "ls -lsa /Volumes/${USER}" + end + +end diff --git a/homebrew-osx-ramdisk/readme.md b/homebrew-osx-ramdisk/readme.md new file mode 100644 index 0000000..8058070 --- /dev/null +++ b/homebrew-osx-ramdisk/readme.md @@ -0,0 +1 @@ +This is homebrew formula for ram-disk creator