Creating abbrevations for commonly used commands in Intellij Idea Terminal

Viewed 73

I have seen some developers use abbrevations for commands in Intellij IDEA Terminal (may be it could be done in any Terminal, just saw it in Intellij) and would like to know how it is done. For example instead of

~/IdeaProjects/MyProject someBranch > mvn clean install

they used just

~/IdeaProjects/MyProject someBranch > mci

I have watched some tutorials how to define variables in a shell, but I am not sure either defining variables is the way how above is made to work, nor how to do it in Intellij. Any idea how it is realised? Not sure with what searchterm I should google.

2 Answers

If you are on a UNIX-like system (e.g. Linux or MacOS), you can define so called "aliases" for commands in your shell.

If you are using the Bash shell for example, you can define aliases in it's configuration file ~/.bashrc like so:

alias mci="maven clean install"

Just add this line, restart your terminal and typing mci will to exactly the same as maven clean install. This article gives some more information about aliases in the Bash shell if you want to learn more.

If you're using windows, then you can make use of doskey.

E.g. type doskey mci=mvn clean install in the terminal which will then create the alias mci.

Related