26

I'm using IntelliJ's embedded terminal with the fish shell, which works well with one exception: it does not seem to load the fish functions defined in ~/.config/fish/functions/*.

When I use the macOS Terminal.app or iTerm2, the functions get loaded as they are supposed to, only IntelliJ's embedded terminal fails to do so.

Oddly enough, the IntelliJ terminal does load ~/.config/fish/config.fish just fine.

Here's the output of echo $fish_function_path in iterm2 and Terminal.app:

/Users/moritz/.config/fish/functions
/usr/local/Cellar/fish/2.6.0/etc/fish/functions
/usr/local/share/fish/vendor_functions.d
/usr/local/Cellar/fish/2.6.0/share/fish/functions

And here's the output when running the same in IntelliJ's embedded terminal:

/Applications/IntelliJ IDEA.app/Contents/plugins/terminal/fish/functions
/usr/local/Cellar/fish/2.6.0/etc/fish/functions
/usr/local/share/fish/vendor_functions.d
/usr/local/Cellar/fish/2.6.0/share/fish/functions

I guess this looks like IntelliJ's embedded terminal initializes the fish session with a different value for $fish_function_path?

$HOME (=/Users/moritz) and $XDG_CONFIG_HOME (not set) are the same in all three, iTerm2, Terminal.app and IntelliJ's embedded terminal.

anothernode
  • 5,100
  • 13
  • 43
  • 62
  • 2
    Please follow this issue: https://youtrack.jetbrains.com/issue/IDEA-173259 for updates. – Andrey Oct 06 '17 at 15:38
  • Insufficient, and contradictory, information :-) If fish is able to find config.fish it should have no difficulty autoloading functions from your personal functions directory. When running fish inside IntelliJ what is $HOME and $XDG_CONFIG_HOME set to? Assuming the former is set but not the latter what does "ls -ld $HOME/.config/fish/functions" output? What is $fish_function_path set to? If you create a trivial autoloaded function, say "function ij; echo ij ran; end" in $HOME.config/fish/functions/ij.fish can you run that function by just typing "ij"? – Kurtis Rader Oct 06 '17 at 22:21
  • What does `echo $fish_function_path` show? Is there a difference between its output under IntellJ's terminal vs Terminal.app? – ridiculous_fish Oct 07 '17 at 02:06
  • Hi Kurtis Rader, I can run that function in iTerm2 and Terminal.app, but not in IntelliJ's embedded terminal. The aliases I defined in `config.fish` work even in IntelliJ's embedded terminal, though. Sorry if that's contradictory, but it is how it is ;-) – anothernode Oct 07 '17 at 07:44

5 Answers5

52

I was able to get the same result from echo $fish_function_path in IntelliJ's embeded terminal and iTerm2 by going to Settings | Terminal then turning off Shell integration.

I was using phpStorm 2017.3.4 but I assume this will also work in any IntelliJ embedded terminal.

ook
  • 655
  • 6
  • 6
  • 1
    Oh, yeah, that actually seems to work! Much easier solution than mine. Thanks! I'll accept this one and I think you could safely remove the last precautionary statement in your answer, if you like. – anothernode Jun 11 '18 at 21:19
  • Although, I wonder what exactly that "Shell integration" is about anyway and what side effects it could have to turn it off...? – anothernode Jun 13 '18 at 10:52
  • 1
    Not sure exactly what the Shell Integration does, but it is documented here https://www.jetbrains.com/help/idea/settings-tools-terminal.html. I found the `fish.config` file that IntelliJ use, and decided I could live without :-) – Emil Oct 31 '18 at 11:36
37

Check the intelliJ option. Turn off shell integration.

enter image description here

CookAtRice
  • 990
  • 9
  • 10
  • I had a slightly different problem: My Fish prompt wasn't been displayed on Webstorm's terminal. I disabled this `Shell integration` option and it solved the problem. – Jefferson Lima Jan 20 '22 at 17:32
10

Someone posted a good solution for this in the IntelliJ bug tracker.

IntelliJ has its own config.fish, where .config/fish/config.fish does get loaded, but not the functions...

Add the following to IntelliJ's internal config.fish and the fish functions get loaded fine in IntelliJ's embedded terminal:

if test -d ~/.config/fish/functions
  for f in ~/.config/fish/functions/*.fish
    source $f
  end
end

The location of IntelliJ's config.fish varies, on macOS it could be

  • Ultimate Edition: /Applications/IntelliJ\ IDEA.app/Contents/plugins/terminal/fish/config.fish
  • Community Edition: /Applications/IntelliJ\ IDEA\ CE.app/Contents/plugins/terminal/fish/config.fish
  • Or even something like this, if installed via Jetbrains Toolbox: ~/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.4574.11/IntelliJ IDEA.app/Contents/plugins/terminal/fish

You could also just replace that whole fish directory in IntelliJ's plugins/terminal with a symlink to your normal fish config directory, usually .config/fish/.

There's still another option: you can just link the functions directory, for example:

ln -s ~/.config/fish/functions \
  /Applications/IntelliJ\ IDEA.app/Contents/plugins/terminal/fish/config.fish
anothernode
  • 5,100
  • 13
  • 43
  • 62
  • 1
    I found a much easier way, just delete IDEA's fish directory and create a soft link to user's. – Sraw Mar 28 '18 at 09:25
  • That's a good approach, too, although somewhat more invasive as it also overrides that `fishd.` file that is also there which doesn't work very well with my setup for some reason. – anothernode Mar 28 '18 at 09:47
2

For me since since i use bass which also put some .py file in that directory, I have to tweak this a tad.

if test -d ~/.config/fish/functions
  for f in ~/.config/fish/functions/*.fish
    source $f
  end
end

Also I found the Ultimate Edition's path is a bit different: /Applications/IntelliJ\ IDEA.app/Contents/plugins/terminal/fish/config.fish

LeOn - Han Li
  • 9,388
  • 1
  • 65
  • 59
0

I still have the same problem in IntelliJ 2018.1 and also in Clion 2018.1. I tried to fix in Clion by suggestions in this thread, but someway it did not worked (I got even more error messages even if all seemed to be OK).

So my workaround solution is to set Idea terminal to /bin/bash (in Settings/Tools/Terminal - Shell Path), then as first command in terminal window enter fish.. and everything works fine, no fiddling with terminal plugin is needed.

(I find it quite a pity, that Jetbrain can't/doesn't want to fix it.. and /IDEA-173259 is "closed")

Nightingale7
  • 311
  • 2
  • 6