Recently I wanted to change the prompt in the terminal when using IntelliJ. I have a development prompt that I like to use whenever I am developing and wanted IntelliJ to also use it.
If you just point the terminal in IntelliJ to a script that sets your prompt, it will not work. It simply runs that script and fails to open the terminal. There are a few solutions to the problem if you are using bash (thanks thrig!).
- Method 1: Running
bash --rcfile mycustomrcwill read whatever customizations you need from the given file. It may also be helpful to use the
--noprofileflags depending on whether you do or do not want the
mycustomrcto mix with the standard shell settings.
- Method 2: Use an environmental flag to determine whether or not to load the custom settings in the standard shell settings files.
- Method 3: Feed the custom shell configuration into a new
bashprocess, then interact with it. See e.g.
zcomppoke.1for this pattern in action.
I choose method #1 since it was the simplest for what I wanted, and did not require me to add an environment variable before it would work.
To make this work, I had to set the terminal prompt as follows:
/bin/bash --rcfile ~/.dotfiles/dev_bashrc
That was all there is to it, the dev_bashrc is in my dotfiles repo on github. It simply changes the prompt and loads as normal.