diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5b374cc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,26 @@ +# Asimov Change Log + +All notable changes to this project will be documented in this file. + +This project adheres to [Semantic Versioning](http://semver.org/). + + +## [0.2.0] + +* Bundle the script with `com.stevegrunwell.asimov.plist`, enabling Asimov to be scheduled to run daily. Users can set this up in a single step by running the new `install.sh` script. +* Fixed pathing issue when resolving the script directory for `install.sh`. Props @morganestes. (#7) +* Change the scope of Asimov to find matching directories within the current user's home directory, not just `~/Sites`. Props to @vitch for catching this! (#10). +* Added a formal change log to the repository. (#5) + + +## [0.1.0] + +Initial public release. + + +[Unreleased]: https://github.com/stevegrunwell/asimov/compare/master...develop +[0.2.0]: https://github.com/stevegrunwell/asimov/releases/tag/v0.2.0 +[0.1.0]: https://github.com/stevegrunwell/asimov/releases/tag/v0.1.0 +[#10]: https://github.com/stevegrunwell/asimov/issues/10 +[#7]: https://github.com/stevegrunwell/asimov/issues/7 +[#5]: https://github.com/stevegrunwell/asimov/issues/5 \ No newline at end of file diff --git a/README.md b/README.md index 44e95b8..ed3fdb2 100644 --- a/README.md +++ b/README.md @@ -8,19 +8,18 @@ For the average consumer, Time Machine is an excellent choice, especially consid Asimov aims to solve that problem, scanning your filesystem for known dependency directories (e.g. `node_modules/` living adjacent to a `package.json` file) and excluding them from Time Machine backups. After all, why eat up space on your backup drive for something you could easily restore via `npm install`? -## Usage +## Installation -After cloning the repository or downloading and extracting an archive, run the following to automatically exclude dependencies from Time Machine backups: +To get started with Asimov, clone the repository or download and extract an archive anywhere you'd like on your Mac: -```bash -# Make the script executable (you'll only need to do this once). -$ chmod +x ./asimov - -# Run Asimov. -$ ./asimov +```sh +$ git clone git@github.com:stevegrunwell/asimov.git ``` -You may wish to schedule Asimov to run automatically, ensuring new projects are automatically excluded from backups. Don't worry about running it multiple times, Asimov is smart enough to see if a directory has already been marked for exclusion. +After you've cloned the repository, run the `install.sh` script to automatically: +* Symlink Asimov to `/usr/local/bin`, making it readily available from anywhere. +* Schedule Asimov to run once a day, ensuring new projects' dependencies are quickly excluded from Time Machine backups. +* Run Asimov for the first time, finding all current project dependencies adding them to Time Machine's exclusion list. ## How it works @@ -28,6 +27,8 @@ At its essence, Asimov is a simple wrapper around Apple's `tmutil` program, whic Asimov finds recognized dependency directories, verifies that the corresponding dependency file exists and, if so, tells Time Machine not to worry about backing up the dependency directory. +Don't worry about running it multiple times, either. Asimov is smart enough to see if a directory has already been marked for exclusion. + ### Retrieving excluded files If you'd like to see all of the directories and files that have been excluded from Time Machine, you can do so by running the following command ([props Brant Bobby on StackOverflow](https://apple.stackexchange.com/a/25833/206772)): diff --git a/asimov b/asimov index d579686..fc01dd4 100755 --- a/asimov +++ b/asimov @@ -12,7 +12,7 @@ # # For a full explanation, please see https://apple.stackexchange.com/a/25833/206772 # -# @version 0.1.0 +# @version 0.2.0 # @author Steve Grunwell # @license MIT @@ -67,5 +67,5 @@ for i in "${FILEPATHS[@]}"; do printf "\\n\\033[0;36mFinding %s/ directories with corresponding %s files...\\033[0m\\n" \ "${parts[0]}" "${parts[1]}" - find ~/Sites -name "${parts[0]}" -type d | dependency_file_exists "${parts[1]}" | exclude_file + find ~ -name "${parts[0]}" -type d | dependency_file_exists "${parts[1]}" | exclude_file done diff --git a/com.stevegrunwell.asimov.plist b/com.stevegrunwell.asimov.plist new file mode 100644 index 0000000..c8420c6 --- /dev/null +++ b/com.stevegrunwell.asimov.plist @@ -0,0 +1,13 @@ + + + + + Label + com.stevegrunwell.asimov + Program + /usr/local/bin/asimov + StartInterval + + 86400 + + diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..bd388d6 --- /dev/null +++ b/install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Install Asimov as a launchd daemon. +# +# @author Steve Grunwell +# @license MIT + +DIR="$(cd "$(dirname "$0")" || return; pwd -P)" +PLIST="com.stevegrunwell.asimov.plist" + +# Verify that Asimov is executable. +chmod +x ./asimov + +# Symlink Asimov into /usr/local/bin. +echo -e "\\033[0;36mSymlinking ${DIR} to /usr/local/bin/asimov\\033[0m" +ln -si "${DIR}/asimov" /usr/local/bin/asimov + +# If it's already loaded, unload first. +if launchctl list | grep -q com.stevegrunwell.asimov; then + echo -e "\\n\\033[0;36mUnloading current instance of ${PLIST}\\033[0m"; + launchctl unload "${DIR}/${PLIST}" +fi + +# Load the .plist file. +launchctl load "${DIR}/${PLIST}" && echo -e "\\n\\033[0;32mAsimov daemon has been loaded!\\033[0m"; + +# Run Asimov for the first time. +"${DIR}/asimov"