Merge remote-tracking branch 'origin/master'
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 10 Nov 2016 16:35:43 +0000 (17:35 +0100)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 10 Nov 2016 16:35:43 +0000 (17:35 +0100)
platform/build-scripts/groovy/org/jetbrains/intellij/build/CommunityRepositoryModules.groovy
plugins/terminal/resources/fish/config.fish [new file with mode: 0644]
plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
python/python-terminal/src/com/jetbrains/python/sdk/PyVirtualEnvTerminalCustomizer.kt

index c40e8235450897cf498081c9dc27af01940cb535..d035bc0240024bebc25898769c7dc09970ec0906 100644 (file)
@@ -242,6 +242,7 @@ class CommunityRepositoryModules {
     plugin("terminal") {
       withResource("resources/.zshrc", "")
       withResource("resources/jediterm-bash.in", "")
+      withResource("fish/config.fish", "fish")
     }
   ]
 
diff --git a/plugins/terminal/resources/fish/config.fish b/plugins/terminal/resources/fish/config.fish
new file mode 100644 (file)
index 0000000..9b265af
--- /dev/null
@@ -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
\ No newline at end of file
index bdeffe83f598cfb424c6714c5164bf45bc3b47e3..92acaac7586a565a56da60f4d7686b03436fa463 100644 (file)
@@ -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)) {
index 898db01029ea5034a842eb7c514cb3ac2464b9a0..b7573141b42a8ece39d0678d5e9d9907aeaafeaa 100644 (file)
@@ -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") })
           }
         }
-
       }
     }