Kotlin scripts and the terminal
Run Kotlin scripts from the terminal.

The PATH environment variable is where the OS (operative system) search for needed executables
when a command is executed from the CLI.
For example, if you want to run Kotlin scripts you need to add Kotlin to the PATH. There are
different ways to add it based on the OS you are using.
In this example we are going to add Kotlin to the PATH, but you can add any program in a similar
way.
You can download Kotlin from the official GitHub repository by looking at
the last release and downloading the
kotlin-compiler-$version.zip file, where $version is the version you are looking for, usually
the latest one.
.bashrc file in your home directory with a text editor.Add the next line:
export PATH="path/to/kotlin/bin/":$PATH
If the executable is inside your home, you can use $HOME:
export PATH="$HOME/path/to/kotlin/bin":$PATH
.zshrc file in your home directory with a text editor.Add the next line:
export PATH="path/to/kotlin/bin/":$PATH
If the path is inside your home, you can use $HOME:
export PATH="$HOME/path/to/kotlin/bin":$PATH
Environment variables and
open Edit the system environment variables.Environment variables at the bottom.There are environment variables for your user or the whole system.
Both have PATH, you have to decide if you want to add the program for all users or only for
you. Select Path and press the button edit. You will see a list of programs, you can add one
manually by pressing New
or edit one by pressing Edit.
Browse and selecting the location of the bin
directory, for example C:\Program Files\kotlin\bin (or whatever directory where you unzipped
the kotlin-compiler-$version.zip file).Now you will be able to run kotlin scripts in any folder by running the next command in the terminal:
kotlin my-script.main.kts # or whatever name you set to the script file.