Swift tip : Kotlin command line with IntelliJ

A nicer way to make Kotlin available in your command line.

IDE support and developer tools are always there for you. But sometimes, with languages that include a REPL or an interpreter of some sort you’d want to have a quick play in your terminal.

If you fancy Kotlin, it is most likely that you have IntelliJ running right now. You might have also linked Kotlin in your console path as well and you will eventually go to the official site to update those compiler binaries.

Given that you have installed the plugin in the IntelliJ IDE, you don’t have to do that. The plugin already includes that tool. Also, IntelliJ notifies you whenever a new version of it is available (which is quite frequent!), so you get updates for free.

Assuming that you’re on Linux and the IntelliJ IDEA settings are on the default location:

export KOTLIN_HOME=~/.IdeaIC15/config/plugins/Kotlin
chmod +x $KOTLIN_HOME/bin/*

Add those entries to your “.bashrc” or whatever depending upon your console setup. And reload your terminal or enter:

source .bashrc

One thing is important here, this applies to IntelliJ IDEA 15, if you’re on a different version copy-pasting those lines won’t work. The main idea is to add the plugin path in some environment variable to let the command line know of those binaries.