Add possibility to customize terminal environment variables
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 6 Jul 2016 12:47:17 +0000 (14:47 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 6 Jul 2016 12:48:48 +0000 (14:48 +0200)
plugins/terminal/resources/META-INF/terminal.xml
plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalCustomizer.java [new file with mode: 0644]
plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java

index 7fa3b27a7c3037b1fb55a6cf0ddb62ae0d46ecb9..0906025d480921d166147de22d7b0d30b93be49b 100644 (file)
@@ -18,4 +18,9 @@
       <implementation-class>org.jetbrains.plugins.terminal.TerminalView</implementation-class>
     </component>
   </project-components>
+
+  <extensionPoints>
+    <extensionPoint qualifiedName="org.jetbrains.plugins.terminal.localTerminalCustomizer"
+                    interface="org.jetbrains.plugins.terminal.LocalTerminalCustomizer"/>
+  </extensionPoints>
 </idea-plugin>
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalCustomizer.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalCustomizer.java
new file mode 100644 (file)
index 0000000..1768a79
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.terminal;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Map;
+
+/**
+ * @author traff
+ */
+public interface LocalTerminalCustomizer {
+  ExtensionPointName<LocalTerminalCustomizer> EP_NAME =
+    ExtensionPointName.create("org.jetbrains.plugins.terminal.localTerminalCustomizer");
+
+  void setupEnvironment(@NotNull  Map<String, String> envs);
+}
index d7cb0abad2fa18726761e77fb6b197d8cdddf655..65504be072f6e8519f4fc70ff32442de52eab8c2 100644 (file)
@@ -27,7 +27,6 @@ import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.vfs.CharsetToolkit;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.Consumer;
 import com.intellij.util.concurrency.AppExecutorUtil;
 import com.intellij.util.containers.HashMap;
 import com.jediterm.pty.PtyProcessTtyConnector;
@@ -94,6 +93,11 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
       envs.put("TERM", "xterm-256color");
     }
     EncodingEnvironmentUtil.setLocaleEnvironmentIfMac(envs, myDefaultCharset);
+    
+    for (LocalTerminalCustomizer customizer: LocalTerminalCustomizer.EP_NAME.getExtensions()) {
+      customizer.setupEnvironment(envs);
+    }
+    
     try {
       return PtyProcess.exec(getCommand(), envs, directory != null ? directory : currentProjectFolder());
     }