Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created October 24, 2011 06:01
Show Gist options
  • Save westonruter/1308447 to your computer and use it in GitHub Desktop.
Save westonruter/1308447 to your computer and use it in GitHub Desktop.
Script for opening Komodo from the (Mac) command line
#!/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
@dch
Copy link

dch commented May 11, 2015

FWIW I came up with this:

ko () {
    open -a Komodo
    /usr/bin/touch $*
    ~/Applications/Komodo.app/Contents/MacOS/komodo $*
}

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment