mirror of
https://github.com/Eugeny/tabby.git
synced 2025-01-18 14:04:17 +08:00
autodetect powershell core path (fixes #382)
This commit is contained in:
parent
d574f634c9
commit
bf5e460bca
@ -35,6 +35,7 @@ import { GitBashShellProvider } from './shells/gitBash'
|
|||||||
import { LinuxDefaultShellProvider } from './shells/linuxDefault'
|
import { LinuxDefaultShellProvider } from './shells/linuxDefault'
|
||||||
import { MacOSDefaultShellProvider } from './shells/macDefault'
|
import { MacOSDefaultShellProvider } from './shells/macDefault'
|
||||||
import { POSIXShellsProvider } from './shells/posix'
|
import { POSIXShellsProvider } from './shells/posix'
|
||||||
|
import { PowerShellCoreShellProvider } from './shells/powershellCore'
|
||||||
import { WindowsStockShellsProvider } from './shells/windowsStock'
|
import { WindowsStockShellsProvider } from './shells/windowsStock'
|
||||||
import { WSLShellProvider } from './shells/wsl'
|
import { WSLShellProvider } from './shells/wsl'
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ import { hterm } from './hterm'
|
|||||||
{ provide: ShellProvider, useClass: Cygwin64ShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: Cygwin64ShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: GitBashShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: GitBashShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: POSIXShellsProvider, multi: true },
|
{ provide: ShellProvider, useClass: POSIXShellsProvider, multi: true },
|
||||||
|
{ provide: ShellProvider, useClass: PowerShellCoreShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: WSLShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: WSLShellProvider, multi: true },
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
|
48
terminus-terminal/src/shells/powershellCore.ts
Normal file
48
terminus-terminal/src/shells/powershellCore.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import * as path from 'path'
|
||||||
|
import { Injectable } from '@angular/core'
|
||||||
|
import { HostAppService, Platform } from 'terminus-core'
|
||||||
|
|
||||||
|
import { ShellProvider, IShell } from '../api'
|
||||||
|
|
||||||
|
let Registry = null
|
||||||
|
try {
|
||||||
|
Registry = require('winreg')
|
||||||
|
} catch (_) { } // tslint:disable-line no-empty
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class PowerShellCoreShellProvider extends ShellProvider {
|
||||||
|
constructor (
|
||||||
|
private hostApp: HostAppService,
|
||||||
|
) {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
|
||||||
|
async provide (): Promise<IShell[]> {
|
||||||
|
if (this.hostApp.platform !== Platform.Windows) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
let pwshPath = await new Promise<string>(resolve => {
|
||||||
|
let reg = new Registry({ hive: Registry.HKLM, key: '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\pwsh.exe', arch: 'x64' })
|
||||||
|
reg.get('', (err, item) => {
|
||||||
|
if (err || !item) {
|
||||||
|
return resolve(null)
|
||||||
|
}
|
||||||
|
resolve(item.value)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!pwshPath) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return [{
|
||||||
|
id: 'powershell-core',
|
||||||
|
name: 'PowerShell Core',
|
||||||
|
command: pwshPath,
|
||||||
|
env: {
|
||||||
|
TERM: 'cygwin',
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
@ -42,14 +42,6 @@ export class WindowsStockShellsProvider extends ShellProvider {
|
|||||||
TERM: 'cygwin',
|
TERM: 'cygwin',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'powershell-core',
|
|
||||||
name: 'PowerShell Core',
|
|
||||||
command: 'pwsh.exe',
|
|
||||||
env: {
|
|
||||||
TERM: 'cygwin',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user