Add option to use bash\zsh from users’s env #307

This commit is contained in:
Alex Mazanov 2022-04-16 15:39:29 -04:00
parent b4ef58244b
commit 366695d594
No known key found for this signature in database
GPG Key ID: FD35C3C7C1D34AB4
2 changed files with 21 additions and 4 deletions

View File

@ -7,8 +7,14 @@ enum TerminalOptions: String, CaseIterable {
}
enum ShellOptions: String, CaseIterable {
case Bash
case Zsh
case Bash = "bash"
case Zsh = "zsh"
case BashEnv = "bash(env)"
case ZshEnv = "zsh(env)"
var envPath: String {
"/usr/bin/env"
}
var path: String {
switch self {
@ -16,6 +22,10 @@ enum ShellOptions: String, CaseIterable {
return "/bin/bash"
case .Zsh:
return "/bin/zsh"
case .BashEnv:
return "bash"
case .ZshEnv:
return "zsh"
}
}
}

View File

@ -46,8 +46,15 @@ private extension Process {
executableURL = URL(fileURLWithPath: script)
arguments = args
} else {
executableURL = URL(fileURLWithPath: delegate.prefs.shell.path)
arguments = ["-c", "-l", "\(script.escaped()) \(args.joined(separator: " "))"]
let shell = delegate.prefs.shell
switch shell {
case .Bash, .Zsh:
executableURL = URL(fileURLWithPath: shell.path)
arguments = ["-c", "-l", "\(script.escaped()) \(args.joined(separator: " "))"]
case .BashEnv, .ZshEnv:
executableURL = URL(fileURLWithPath: shell.envPath)
arguments = [shell.path, "-c", "-l", "\(script.escaped()) \(args.joined(separator: " "))"]
}
}
guard let executableURL = executableURL, FileManager.default.fileExists(atPath: executableURL.path) else {