mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-19 19:09:54 +00:00
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import * as path from 'path'
|
|
import { Injectable } from '@angular/core'
|
|
import { getRegistryValue, HK } from 'windows-native-registry'
|
|
import { HostAppService, Platform } from 'terminus-core'
|
|
|
|
import { ShellProvider, IShell } from '../api'
|
|
|
|
@Injectable()
|
|
export class GitBashShellProvider extends ShellProvider {
|
|
constructor (
|
|
private hostApp: HostAppService,
|
|
) {
|
|
super()
|
|
}
|
|
|
|
async provide (): Promise<IShell[]> {
|
|
if (this.hostApp.platform !== Platform.Windows) {
|
|
return []
|
|
}
|
|
|
|
let gitBashPath = getRegistryValue(HK.LM, 'Software\\GitForWindows', 'InstallPath')
|
|
|
|
if (!gitBashPath) {
|
|
gitBashPath = getRegistryValue(HK.CU, 'Software\\GitForWindows', 'InstallPath')
|
|
}
|
|
|
|
if (!gitBashPath) {
|
|
return []
|
|
}
|
|
|
|
return [{
|
|
id: 'git-bash',
|
|
name: 'Git-Bash',
|
|
command: path.join(gitBashPath, 'bin', 'bash.exe'),
|
|
args: [ '--login', '-i' ],
|
|
env: {
|
|
TERM: 'cygwin',
|
|
}
|
|
}]
|
|
}
|
|
}
|