#7315 - added terminal identification option on windows

This commit is contained in:
Eugene Pankov
2023-01-27 22:40:16 +01:00
parent 5e2976ab3d
commit 842636aa15
10 changed files with 2218 additions and 26 deletions

View File

@@ -1,8 +1,9 @@
import * as path from 'path'
import { Injectable } from '@angular/core'
import { HostAppService, Platform } from 'tabby-core'
import { Platform, ConfigService, HostAppService } from 'tabby-core'
import { ShellProvider, Shell } from '../api'
import { Shell } from '../api'
import { WindowsBaseShellProvider } from './windowsBase'
/* eslint-disable block-scoped-var */
@@ -12,11 +13,13 @@ try {
/** @hidden */
@Injectable()
export class GitBashShellProvider extends ShellProvider {
export class GitBashShellProvider extends WindowsBaseShellProvider {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor (
private hostApp: HostAppService,
hostApp: HostAppService,
config: ConfigService,
) {
super()
super(hostApp, config)
}
async provide (): Promise<Shell[]> {
@@ -40,9 +43,7 @@ export class GitBashShellProvider extends ShellProvider {
command: path.join(gitBashPath, 'bin', 'bash.exe'),
args: ['--login', '-i'],
icon: require('../icons/git-bash.svg'),
env: {
TERM: 'cygwin',
},
env: this.getEnvironment(),
}]
}
}

View File

@@ -1,7 +1,8 @@
import { Injectable } from '@angular/core'
import { HostAppService, Platform } from 'tabby-core'
import { HostAppService, ConfigService, Platform } from 'tabby-core'
import { ShellProvider, Shell } from '../api'
import { Shell } from '../api'
import { WindowsBaseShellProvider } from './windowsBase'
/* eslint-disable block-scoped-var */
@@ -11,11 +12,13 @@ try {
/** @hidden */
@Injectable()
export class PowerShellCoreShellProvider extends ShellProvider {
export class PowerShellCoreShellProvider extends WindowsBaseShellProvider {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor (
private hostApp: HostAppService,
hostApp: HostAppService,
config: ConfigService,
) {
super()
super(hostApp, config)
}
async provide (): Promise<Shell[]> {
@@ -35,9 +38,7 @@ export class PowerShellCoreShellProvider extends ShellProvider {
command: pwshPath,
args: ['-nologo'],
icon: require('../icons/powershell-core.svg'),
env: {
TERM: 'cygwin',
},
env: this.getEnvironment(),
}]
}
}

View File

@@ -42,7 +42,6 @@ export class WindowsDefaultShellProvider extends ShellProvider {
id: 'default',
name: this.translate.instant('OS default ({name})', shell),
hidden: true,
env: {},
}]
}
}

View File

@@ -0,0 +1,23 @@
import { ConfigService, HostAppService } from 'tabby-core'
import { ShellProvider } from '../api'
export abstract class WindowsBaseShellProvider extends ShellProvider {
constructor (
protected hostApp: HostAppService,
protected config: ConfigService,
) {
super()
}
protected getEnvironment (): any {
return {
wt: {
WT_SESSION: 0,
},
cygwin: {
TERM: 'cygwin',
},
}[this.config.store.terminal.identification] ?? {}
}
}

View File

@@ -2,19 +2,21 @@ import * as path from 'path'
import * as fs from 'fs/promises'
import hasbin from 'hasbin'
import { Injectable } from '@angular/core'
import { HostAppService, Platform } from 'tabby-core'
import { HostAppService, Platform, ConfigService } from 'tabby-core'
import { ElectronService } from 'tabby-electron'
import { ShellProvider, Shell } from '../api'
import { Shell } from '../api'
import { WindowsBaseShellProvider } from './windowsBase'
/** @hidden */
@Injectable()
export class WindowsStockShellsProvider extends ShellProvider {
export class WindowsStockShellsProvider extends WindowsBaseShellProvider {
constructor (
private hostApp: HostAppService,
hostApp: HostAppService,
config: ConfigService,
private electron: ElectronService,
) {
super()
super(hostApp, config)
}
async provide (): Promise<Shell[]> {
@@ -64,9 +66,7 @@ export class WindowsStockShellsProvider extends ShellProvider {
command: await this.getPowerShellPath(),
args: ['-nologo'],
icon: require('../icons/powershell.svg'),
env: {
TERM: 'cygwin',
},
env: this.getEnvironment(),
},
]
}