mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
fix<MacOS>: new way to launch Terminal.app
This commit is contained in:
parent
d74a3fb550
commit
a644a04b17
1 changed files with 15 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace SourceGit.Native {
|
namespace SourceGit.Native {
|
||||||
[SupportedOSPlatform("macOS")]
|
[SupportedOSPlatform("macOS")]
|
||||||
|
@ -31,11 +32,20 @@ namespace SourceGit.Native {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenTerminal(string workdir) {
|
public void OpenTerminal(string workdir) {
|
||||||
Process.Start(new ProcessStartInfo() {
|
var dir = string.IsNullOrEmpty(workdir) ? "~" : workdir;
|
||||||
WorkingDirectory = workdir,
|
var builder = new StringBuilder();
|
||||||
FileName = "/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal",
|
builder.AppendLine("on run argv");
|
||||||
UseShellExecute = false,
|
builder.AppendLine(" tell application \"Terminal\"");
|
||||||
});
|
builder.AppendLine($" do script \"cd '{dir}'\"");
|
||||||
|
builder.AppendLine(" activate");
|
||||||
|
builder.AppendLine(" end tell");
|
||||||
|
builder.AppendLine("end run");
|
||||||
|
|
||||||
|
var tmp = Path.GetTempFileName();
|
||||||
|
File.WriteAllText(tmp, builder.ToString());
|
||||||
|
|
||||||
|
var proc = Process.Start("/usr/bin/osascript", $"\"{tmp}\"");
|
||||||
|
proc.Exited += (o, e) => File.Delete(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenWithDefaultEditor(string file) {
|
public void OpenWithDefaultEditor(string file) {
|
||||||
|
|
Loading…
Reference in a new issue