Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change ${USER} variable in IntelliJ IDEA without changing OS user name?

By ${USER} Intellij idea means the login name of the current user. But what if login differ from name used as developer name? Is it possible to set USER to other value without changing OS login name?

like image 682
Cherry Avatar asked Oct 15 '15 02:10

Cherry


People also ask

How do I change a variable name in IntelliJ?

Press Shift+F6 or from the main menu, select Refactor | Rename. next to the highlighted element. You can press Tab to open the context menu and select the additional rename options. If you want to see the Rename dialog with more options, click the More options link or press Shift+F6 .

How do I change environment variables in IntelliJ?

Add environment variablesFrom the main menu, select Run | Edit Configurations or choose Edit Configurations from the run/debug configurations selector on the toolbar. In the Run/Debug Configurations dialog, select a configuration you want to add the environment variables to.


2 Answers

You can modify the file idea.exe.vmoptions or idea64.exe.vmoptions, which should be in the bin folder of your IDE installation. For linux version, it could be idea.vmoptions. You need to add there a parameter:

-Duser.name=YOURNAME 

How to open the file:

  • Ctrl+Shift+A > type "vm options" > select option
  • Help > Edit custom VM options...

This would make your ${USER} variable inside IntelliJ Idea equals to parameter value and you don't have to change the current OS user login name. I've just tested it in the IntelliJ Idea 14.1.3 with file and code templates.

like image 189
Stanislav Avatar answered Sep 30 '22 08:09

Stanislav


To change the ${USER} variable for just the current user (rather than system wide) select Help->Edit Custom VM Options and add the following to the file that opens in your editor:

-Duser.name=USER 

Then save the file and restart your editor.

https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties

like image 23
Alex Dioso Avatar answered Sep 30 '22 07:09

Alex Dioso