There's a command for that:
open.
This is the simplest way: you just have to type the filename.
open myFile.extopen Main.javaYou just have to add the name of the app preceded by -a.
Note: you have the choice to type the filename before or after the
-a myApp.
open myFile.ext -a myApp
# or
open -a myApp myFile.extopen Main.java -a atomYou can create an alias to go faster.
Example:
alias idea="open -a 'IntelliJ IDEA'"