gitBash.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import * as path from 'path'
  2. import { Injectable } from '@angular/core'
  3. import { getRegistryValue } from 'windows-native-registry'
  4. import { HostAppService, Platform } from 'terminus-core'
  5. import { ShellProvider, IShell } from '../api'
  6. @Injectable()
  7. export class GitBashShellProvider extends ShellProvider {
  8. constructor (
  9. private hostApp: HostAppService,
  10. ) {
  11. super()
  12. }
  13. async provide (): Promise<IShell[]> {
  14. if (this.hostApp.platform !== Platform.Windows) {
  15. return []
  16. }
  17. let gitBashPath = getRegistryValue('HKLM', 'Software\\GitForWindows', 'InstallPath')
  18. if (!gitBashPath) {
  19. gitBashPath = getRegistryValue('HKCU', 'Software\\GitForWindows', 'InstallPath')
  20. }
  21. if (!gitBashPath) {
  22. return []
  23. }
  24. return [{
  25. id: 'git-bash',
  26. name: 'Git-Bash',
  27. command: path.join(gitBashPath, 'bin', 'bash.exe'),
  28. args: [ '--login', '-i' ],
  29. env: {
  30. TERM: 'cygwin',
  31. }
  32. }]
  33. }
  34. }