mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Provide fish shell integration with the terminal (IDEA-163063)
This commit is contained in:
+1
@@ -242,6 +242,7 @@ class CommunityRepositoryModules {
|
||||
plugin("terminal") {
|
||||
withResource("resources/.zshrc", "")
|
||||
withResource("resources/jediterm-bash.in", "")
|
||||
withResource("fish/config.fish", "fish")
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
if test -f ~/.config/fish/config.fish
|
||||
. ~/.config/fish/config.fish
|
||||
end
|
||||
|
||||
if test -n "$JEDITERM_USER_RCFILE"
|
||||
. $JEDITERM_USER_RCFILE
|
||||
end
|
||||
|
||||
if test -n "$JEDITERM_SOURCE"
|
||||
. $JEDITERM_SOURCE
|
||||
end
|
||||
@@ -57,6 +57,8 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
|
||||
private static final Logger LOG = Logger.getInstance(LocalTerminalDirectRunner.class);
|
||||
public static final String JEDITERM_USER_RCFILE = "JEDITERM_USER_RCFILE";
|
||||
public static final String ZDOTDIR = "ZDOTDIR";
|
||||
public static final String XDG_CONFIG_HOME = "XDG_CONFIG_HOME";
|
||||
|
||||
|
||||
private final Charset myDefaultCharset;
|
||||
|
||||
@@ -79,10 +81,11 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
|
||||
shellName = "bash";
|
||||
}
|
||||
try {
|
||||
|
||||
String rcfile = "jediterm-" + shellName + ".in";
|
||||
if ("zsh".equals(shellName)) {
|
||||
rcfile = ".zshrc";
|
||||
} else if ("fish".equals(shellName)) {
|
||||
rcfile = "fish/config.fish";
|
||||
}
|
||||
URL resource = LocalTerminalDirectRunner.class.getClassLoader().getResource(rcfile);
|
||||
if (resource != null && "jar".equals(resource.getProtocol())) {
|
||||
@@ -203,6 +206,16 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
|
||||
}
|
||||
envs.put(ZDOTDIR, new File(rcFilePath).getParent());
|
||||
}
|
||||
else if (shellName.equals("fish")) {
|
||||
if (StringUtil.isNotEmpty(EnvironmentUtil.getEnvironmentMap().get(XDG_CONFIG_HOME))) {
|
||||
File fishConfig = new File(new File(FileUtil.expandUserHome(envs.get(XDG_CONFIG_HOME)), "fish"), "config.fish");
|
||||
if (fishConfig.exists()) {
|
||||
envs.put(JEDITERM_USER_RCFILE, fishConfig.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
envs.put(XDG_CONFIG_HOME, new File(rcFilePath).getParentFile().getParent());
|
||||
}
|
||||
}
|
||||
|
||||
if (!loginOrInteractive(command)) {
|
||||
|
||||
+1
-2
@@ -45,7 +45,7 @@ class PyVirtualEnvTerminalCustomizer : LocalTerminalCustomizer() {
|
||||
val shellPath = command[0]
|
||||
val shellName = File(shellPath).name
|
||||
|
||||
if (shellName == "bash" || (SystemInfo.isMac && shellName == "sh") || (shellName == "zsh")) {
|
||||
if (shellName == "bash" || (SystemInfo.isMac && shellName == "sh") || (shellName == "zsh") || (shellName == "fish")) {
|
||||
//for bash we pass activate script to jediterm shell integration (see jediterm-bash.in) to source it there
|
||||
findActivateScript(path, shellPath)?.let { activate -> envs.put("JEDITERM_SOURCE", activate) }
|
||||
}
|
||||
@@ -56,7 +56,6 @@ class PyVirtualEnvTerminalCustomizer : LocalTerminalCustomizer() {
|
||||
envs.putAll(reader.readShellEnv().filterKeys { k -> k in arrayOf("PATH", "PS1", "VIRTUAL_ENV", "PYTHONHOME") })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user