Komodo from the command-line

Posted by troyt on 2011-01-07 10:23
OS: All / Any | Product: Komodo | tags: cli command line komodo shell
Question: 

How do I use Komodo from the command-line?

Answer: 

First, add it to your system PATH or create an alias. These examples use Komodo IDE 6.0, but you can modify them for any version.

  • Windows users: komodo.exe should be added to the PATH during installation.
  • Linux users: you can either add Komodo's 'bin' directory to your PATH:

    export PATH=$PATH:/opt/Komodo-IDE-8/bin

    ...or create a symlink as suggested at the end of the installation process:

    ln -sf /opt/Komodo-IDE-6.0/bin/komodo $HOME/bin/komodo

  • OS X users: use the 'alias' command:

    alias komodo='open -a "Komodo IDE 8"'

  • ... or alternately, you can also specify the path to the application like this:

    alias komodo='open -a "/Applications/Komodo IDE 8"'

You should then be able to start it from a shell or console. If Komodo is already running, a file given as an argument will be opened in the existing instance in a new tab:

komodo ~/this/that/myfile.py

There are additional options. These options will only work with Mac if used on the full path command for Komodo. They will not work with the alias created above. Running komodo --help gets you:

Komodo IDE 6.0 -- ActiveState's cross-platform multi-language IDE

Komodo IDE is cross-platform integrated development environment
with a rich feature set for client-side Ajax languages such as
CSS, HTML, JavaScript and XML, coupled with advanced support for
dynamic languages such as Perl, PHP, Python, Ruby and Tcl.

Usage:

    komodo [options] [...]

Options:
    -h, --help   	show this help and exit
    -V, --version	print the Komodo version and exit
    -v, --verbose	show verbose startup and runtime info

    -n, --new-window	open a new Komodo window
    -l , --line=
        Open the given file(s) at a specific line; use
        , to open at a specific line and column.
        Alternatively, a line can be specified with a 
        pseudo-HTML-anchor syntax, e.g.: 'komodo myscript.pl#42'
        will open 'myscript.pl' at line 42.
    -s , --selection=
        Select a specific range in the given file(s);
         must be one of the following forms:
            1,5-2,15	select from line 1 and column 5
                    	to line 2 column 15
            15-22   	select from character 15 to 22

So specifying a line number with a file would look like this:

komodo -l 42 ~/this/that/myfile.php

Alternatively, you can use a pseudo-HTML-anchor syntax:

komodo myscript.pl#42

This will open 'myscript.pl' at line 42. If you want to get fancy, you can even specify a selection range:

komodo -s 1,0-43,0 ~/this/that/myfile.php

ethan | Wed, 2007-04-04 09:29

Just a word of caution when setting the $PATH variable on Linux.

One should not use the above configuration since it places the Komodo 'bin' directory ahead of essential system binaries.

It is far safer to place the Komodo 'bin' directory after the existing $PATH variable.

This will prevent a user from establishing binaries that masquerade as oft used ones.

Hope this makes sense.

See below:

Bad...

export PATH=/opt/Komodo-IDE-4.1/bin:"${PATH}"

Good...

export PATH="${PATH}":/opt/Komodo-IDE-4.1/bin

Ethan Cane
Promoting W3C Standards for the Web

jeff.griffiths | Wed, 2007-04-04 10:31

Technically, yes you are correct. I guess I don't have a problem putting komodo's bin at the front of the path because there isn't anything in there by default that
would interfere with a Linux system. I agree that it might be possible to install other things in that directory that subvert the system's behavior, but in the above example /op/Komodo-4.1 is owned by root anyway.
--
JeffG

ethan | Thu, 2007-04-05 02:30

No worries dude, I am still something of a Linux noob so am learning stuff all the time.

Thought I would throw in my two cents.

Beginning to like Komodo all over again (on Linux) :-)

Laters

Ethan Cane
Promoting W3C Standards for the Web

Rimian | Fri, 2008-10-24 17:41

Hello,

Oh no! I have no /Users/username/bin directory.

jeff.griffiths | Mon, 2008-10-27 12:17

Yeah, from a stock OS X installation you will of course need to create the bin directory in your user directory. Or you can really use *any* directory to create the symlink in as lng as that directory is on your PATH.

--
JeffG
http://www.openkomodo.com/blogs/jeffg

simon29 | Mon, 2008-12-01 19:30

On Komodo IDE 4.4 on Mac OSX, the komodo command opens a new instance of the application rather than opening the file as a new tab in the already running instance. Bit of a shame, that would've been very handy. I often used Textmate from the command line.

jeff.griffiths | Tue, 2008-12-02 09:53

That's odd, for me with Komodo 4.4 running the command from the command-line always opened a new tab. Are you setting the KOMODO_USERDATADIR environment variable in your shell? Komodo 4.4 should not normally allow more than 1 window, multiple windows were not added as a feature until Komodo 5.

--
JeffG
http://www.openkomodo.com/blogs/jeffg

nrambeck | Fri, 2010-07-30 13:20

This command places symlink in the /usr/local/bin directory. Notice that the command name inside the app package has changed from komodo to komodo-bin.

$ sudo ln -s "/Applications/Komodo IDE.app/Contents/MacOS/komodo-bin" /usr/local/bin/komodo
$ which komodo
/usr/local/bin/komodo

dash_aitch | Tue, 2012-05-08 17:43

I open files in Komodo from the command line in both OSX Terminal and Cygwin on Win7; while the file opens I've found Komodo doesn't come to the foreground - which would be the preferred behaviour for me.

Is there a way to get Komodo to open the file and come to the foreground, particularly on Win7? I've got a hacky solution on OSX but nothing that works on Win7 yet.

(edit: should mention I'm using Komodo Edit, in case it does something different)