mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
#7315 - added terminal identification option on windows
This commit is contained in:
@@ -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(),
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
@@ -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(),
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,6 @@ export class WindowsDefaultShellProvider extends ShellProvider {
|
||||
id: 'default',
|
||||
name: this.translate.instant('OS default ({name})', shell),
|
||||
hidden: true,
|
||||
env: {},
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
23
tabby-local/src/shells/windowsBase.ts
Normal file
23
tabby-local/src/shells/windowsBase.ts
Normal 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] ?? {}
|
||||
}
|
||||
}
|
@@ -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(),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user