fix: launch terminal in current user's home dir failed on macOS(#105)

This commit is contained in:
leo 2024-05-05 13:11:47 +08:00
parent 7da184c55b
commit 9627206764

View file

@ -65,10 +65,12 @@ namespace SourceGit.Native
public void OpenTerminal(string workdir) public void OpenTerminal(string workdir)
{ {
var dir = string.IsNullOrEmpty(workdir) ? "~" : workdir; var dir = string.IsNullOrEmpty(workdir) ? "~" : workdir;
dir = dir.Replace(" ", "\\ ");
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine("on run argv"); builder.AppendLine("on run argv");
builder.AppendLine(" tell application \"Terminal\""); builder.AppendLine(" tell application \"Terminal\"");
builder.AppendLine($" do script \"cd '{dir}'\""); builder.AppendLine($" do script \"cd {dir}\"");
builder.AppendLine(" activate"); builder.AppendLine(" activate");
builder.AppendLine(" end tell"); builder.AppendLine(" end tell");
builder.AppendLine("end run"); builder.AppendLine("end run");