#!/bin/sh

SCRIPT_DIR=$(dirname "$0")
TOOL_PATH="$HOME/Library/Application Support/Kaleidoscope/KaleidoscopeIntegration.alfredworkflow"
TOOL_SRCPATH="$SCRIPT_DIR/KaleidoscopeIntegration.alfredworkflow"

if [ -r "$TOOL_SRCPATH" ] ; then
# echo "Source found $TOOL_SRCPATH"
  :
else
  echo "Could not read integration script source '$TOOL_SRCPATH'" >&2
  exit 1
fi

# Copy integration script to application support
cp "$TOOL_SRCPATH" "$TOOL_PATH" || { echo "Copy to '$TOOL_PATH' failed"; exit 1; }

# Open the alfredworkflow file. This will show Alfred and offer to install it.
open "$TOOL_PATH"

exit 0
