Fixed opening terminal with powershell in windows
This commit is contained in:
parent
8e9f21beee
commit
8cfc3607c2
@ -27,7 +27,7 @@ fun runCommand(command: String): String? {
|
||||
}
|
||||
}
|
||||
|
||||
fun runCommandInPath(command: String, path: String) {
|
||||
fun runCommandInPath(command: List<String>, path: String) {
|
||||
val processBuilder = ProcessBuilder(command).apply {
|
||||
directory(File(path))
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.jetpackduba.gitnuro.extensions.runCommand
|
||||
import com.jetpackduba.gitnuro.extensions.runCommandInPath
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val FLATPAK_PREFIX = "/usr/bin/flatpak-spawn --host --env=TERM=xterm-256color"
|
||||
private val FLATPAK_PREFIX = listOf("/usr/bin/flatpak-spawn", "--host", "--env=TERM=xterm-256color")
|
||||
|
||||
// TODO Test in flatpak
|
||||
class FlatpakTerminalProvider @Inject constructor(
|
||||
@ -22,6 +22,8 @@ class FlatpakTerminalProvider @Inject constructor(
|
||||
}
|
||||
|
||||
override fun startTerminal(terminalEmulator: TerminalEmulator, repositoryPath: String) {
|
||||
runCommandInPath("$FLATPAK_PREFIX ${terminalEmulator.path}", repositoryPath)
|
||||
val command = FLATPAK_PREFIX.toMutableList()
|
||||
command.add(terminalEmulator.path)
|
||||
runCommandInPath(command, repositoryPath)
|
||||
}
|
||||
}
|
@ -22,6 +22,6 @@ class LinuxTerminalProvider @Inject constructor() : ITerminalProvider {
|
||||
}
|
||||
|
||||
override fun startTerminal(terminalEmulator: TerminalEmulator, repositoryPath: String) {
|
||||
runCommandInPath(terminalEmulator.path, repositoryPath)
|
||||
runCommandInPath(listOf(terminalEmulator.path), repositoryPath)
|
||||
}
|
||||
}
|
@ -19,6 +19,6 @@ class MacTerminalProvider @Inject constructor() : ITerminalProvider {
|
||||
}
|
||||
|
||||
override fun startTerminal(terminalEmulator: TerminalEmulator, repositoryPath: String) {
|
||||
runCommandInPath("open -a ${terminalEmulator.path}", repositoryPath)
|
||||
runCommandInPath(listOf("open", "-a", terminalEmulator.path), repositoryPath)
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ class OpenRepositoryInTerminalUseCase @Inject constructor(
|
||||
for (terminal in terminalEmulators) {
|
||||
val isTerminalEmulatorInstalled = terminalProvider.isTerminalInstalled(terminal)
|
||||
if (isTerminalEmulatorInstalled) {
|
||||
runCommandInPath(terminal.path, path)
|
||||
terminalProvider.startTerminal(terminal, path)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,10 @@ package com.jetpackduba.gitnuro.terminal
|
||||
import com.jetpackduba.gitnuro.extensions.runCommandInPath
|
||||
import javax.inject.Inject
|
||||
|
||||
// TODO Test this on windows
|
||||
class WindowsTerminalProvider @Inject constructor() : ITerminalProvider {
|
||||
override fun getTerminalEmulators(): List<TerminalEmulator> {
|
||||
return listOf(
|
||||
TerminalEmulator("Powershell", "powershell"),
|
||||
TerminalEmulator("Powershell", "powershell.exe"),
|
||||
)
|
||||
}
|
||||
|
||||
@ -17,6 +16,6 @@ class WindowsTerminalProvider @Inject constructor() : ITerminalProvider {
|
||||
}
|
||||
|
||||
override fun startTerminal(terminalEmulator: TerminalEmulator, repositoryPath: String) {
|
||||
runCommandInPath("start ${terminalEmulator.path}", repositoryPath)
|
||||
runCommandInPath(listOf("cmd", "/c", "start", terminalEmulator.path), repositoryPath)
|
||||
}
|
||||
}
|
@ -245,7 +245,7 @@ class TabViewModel @Inject constructor(
|
||||
launch {
|
||||
fileChangesWatcher.changesNotifier.collect { latestUpdateChangedGitDir ->
|
||||
if (!tabState.operationRunning) { // Only update if there isn't any process running
|
||||
printLog(TAG, "Detected changes in the repository's directory")
|
||||
printDebug(TAG, "Detected changes in the repository's directory")
|
||||
|
||||
if (latestUpdateChangedGitDir) {
|
||||
hasGitDirChanged = true
|
||||
|
Loading…
Reference in New Issue
Block a user