-
-
Save DarthMoulByte/bb665ea84e5fc3c079f768fd065fa919 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This Editor extension adds a Open Terminal shortcut and menu item to the unity editor. | |
| // Created by 45Ninjas. | |
| // Works for unity 2019.3 running on Linux with Gnome 3.x. | |
| // You should be smart enough to make it work for other versions or operating systems. | |
| using System.Diagnostics; | |
| using UnityEngine; | |
| using UnityEditor; | |
| using UnityEditor.ShortcutManagement; | |
| public class OpenTerminalUtility | |
| { | |
| [MenuItem("File/Open Terminal")] | |
| [Shortcut("OpenTerminal", null, KeyCode.T, ShortcutModifiers.Action, displayName = "Open Terminal")] | |
| public static void OpenTerminal() | |
| { | |
| // Create a new process of the gnome-terminal. | |
| using (Process newProcess = new Process()) | |
| { | |
| // We are using the gnome-terminal executable. | |
| newProcess.StartInfo.FileName = "gnome-terminal"; | |
| // With the --working-directory argument to set the WD to IO's CWD. | |
| newProcess.StartInfo.Arguments = $"--working-directory=\"{System.IO.Directory.GetCurrentDirectory()}\""; | |
| // Plop some output into the console, good or bad is better than none. | |
| if(newProcess.Start()) | |
| UnityEngine.Debug.Log($"Opened gnome-terminal in {System.IO.Directory.GetCurrentDirectory()}"); | |
| else | |
| UnityEngine.Debug.LogWarning("Unable to start gnome-terminal"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment