IntelliJ's embedded terminal does not load fish functions

為{幸葍}努か 提交于 2019-12-03 12:23:27

问题


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.


回答1:


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.




回答2:


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



回答3:


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




回答4:


intelliJ option check. turn off shell integration.




回答5:


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")



来源:https://stackoverflow.com/questions/46609023/intellijs-embedded-terminal-does-not-load-fish-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!