I’m trying to create a command using AppleScript to open CodeKit and select the CodeKit project associated with the current TextMate 2 project.
CodeKit’s docs want this:
tell application "CodeKit" to select project containing path "~/clients/aProject/app.scss”
So I wrote this:
#!/bin/bash [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
osascript <<EOF tell application "CodeKit" to select project containing path "$TM_PROJECT_DIRECTORY" EOF
That launches CodeKit but does not select the project; CodeKit opens to the last used project, not $TM_PROJECT_DIRECTORY.
I’ve tried both “TM_PROJECT_DIRECTORY” and "’$TM_PROJECT_DIRECTORY’”.
What did I get wrong?
Bob ------------------- Robert J. Rockefeller Richmond Hill, GA www.bobrockefeller.com
On 29 Apr 2015, at 1:31, Robert J. Rockefeller wrote:
So I wrote this:
#!/bin/bash osascript <<EOF tell application "CodeKit" to select project containing path "$TM_PROJECT_DIRECTORY" EOF
That launches CodeKit but does not select the project; CodeKit opens to the last used project, not $TM_PROJECT_DIRECTORY.
This is probably more of a CodeKit issue.
Normally you would use: `POSIX file "$TM_PROJECT_DIRECTORY"`.
But given the command is `containing path` then perhaps it does expect a string? Though in the bit you quoted from the documentation it uses a tilde in the path, which is a bit weird, if it’s a subset search.
For testing you could do this:
#!/bin/sh osascript <<EOF tell application "CodeKit" to display alert "Test" message "$TM_PROJECT_DIRECTORY" EOF
This should show if the expected string is actually obtained.
OK, CodeKit does display the expected string in its test dialog box. So it may be a problem on the CodeKit end. I have an email into the developer on that.
Bob ------------------- Robert J. Rockefeller Richmond Hill, GA www.bobrockefeller.com
On Apr 29, 2015, at 10:46 AM, Allan Odgaard mailinglist@textmate.org wrote:
On 29 Apr 2015, at 1:31, Robert J. Rockefeller wrote:
So I wrote this:
#!/bin/bash osascript <<EOF tell application "CodeKit" to select project containing path "$TM_PROJECT_DIRECTORY" EOF
That launches CodeKit but does not select the project; CodeKit opens to the last used project, not $TM_PROJECT_DIRECTORY.
This is probably more of a CodeKit issue.
Normally you would use: `POSIX file "$TM_PROJECT_DIRECTORY"`.
But given the command is `containing path` then perhaps it does expect a string? Though in the bit you quoted from the documentation it uses a tilde in the path, which is a bit weird, if it’s a subset search.
For testing you could do this:
#!/bin/sh osascript <<EOF tell application "CodeKit" to display alert "Test" message "$TM_PROJECT_DIRECTORY" EOF
This should show if the expected string is actually obtained.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Hi Bob,
you have to escape the quotes.
This works for me (also loads the project in Safari):
#!/usr/bin/env bash [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" osascript -e "tell application "CodeKit" to select project containing path "${TM_FILEPATH}""
sleep 3 open http://%24HOSTNAME:5757
echo "set"
-- View this message in context: http://textmate.1073791.n5.nabble.com/Calling-CodeKit-With-AppleScript-tp291... Sent from the textmate users mailing list archive at Nabble.com.