Created
October 24, 2011 06:01
-
-
Save westonruter/1308447 to your computer and use it in GitHub Desktop.
Script for opening Komodo from the (Mac) command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: ko [options] FILE | |
# @author Weston Ruter (@westonruter) | |
# Komodo Edit or Komodo IDE? | |
if [ -e "/Applications/Komodo Edit.app" ]; then | |
app="Komodo Edit" | |
else | |
app="Komodo IDE" | |
fi | |
# Look at arguments and determine target file and if it exists | |
target_file="" | |
for arg in $@; do | |
if [ -e "$arg" ]; then | |
is_target_existing=1 | |
fi | |
if [ ${arg:0:1} != '-' ]; then | |
target_file="$arg" | |
fi | |
done | |
# Instead of having Komodo open the (annoying) dialog box to confirm creation of file, confirm early | |
if [[ $target_file && ! $is_target_existing ]]; then | |
echo "File doesn't exist: $target_file" | |
echo "Hit enter to touch, or kill to abort..." | |
read CONFIRM | |
touch "$target_file" | |
fi | |
# @todo Why can't we pass the arguments $@ directly to the open command with --args? For example: | |
# open -a "$app" --args $@ | |
# Instead I have to do the following: | |
open -a "$app" | |
"/Applications/$app.app/Contents/MacOS/komodo-bin" $@ | |
# Bring the Komodo window into focus (again, the `open` command should suffice here) | |
osascript <<APPLESCRIPT | |
tell application "/Applications/$app.app" | |
activate | |
end tell | |
APPLESCRIPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FWIW I came up with this:
I just touch all files automatically, as my filesystem has update timestamp on access/read disabled this generally doesn't matter.
I like your osascript trick too btw, will add that!