Skip to content

Commit

Permalink
#7315 - added terminal identification option on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Jan 27, 2023
1 parent 5e2976a commit 842636a
Show file tree
Hide file tree
Showing 10 changed files with 2,218 additions and 26 deletions.
2,152 changes: 2,152 additions & 0 deletions config.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tabby-core/src/configDefaults.windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@ hotkeys:
- 'Ctrl-Shift-E'
command-selector:
- 'Ctrl-Shift-P'
terminal:
identification: wt
1 change: 1 addition & 0 deletions tabby-core/src/configDefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ terminal:
showRecentProfiles: 3
paneResizeStep: 0.1
focusFollowsMouse: false
identification: null
hotkeys:
profile:
__nonStructural: true
Expand Down
17 changes: 9 additions & 8 deletions tabby-local/src/shells/gitBash.ts
Original file line number Diff line number Diff line change
@@ -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 */

Expand All @@ -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[]> {
Expand All @@ -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(),
}]
}
}
17 changes: 9 additions & 8 deletions tabby-local/src/shells/powershellCore.ts
Original file line number Diff line number Diff line change
@@ -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 */

Expand All @@ -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[]> {
Expand All @@ -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(),
}]
}
}
1 change: 0 additions & 1 deletion tabby-local/src/shells/winDefault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class WindowsDefaultShellProvider extends ShellProvider {
id: 'default',
name: this.translate.instant('OS default ({name})', shell),
hidden: true,
env: {},
}]
}
}
Expand Down
23 changes: 23 additions & 0 deletions tabby-local/src/shells/windowsBase.ts
Original file line number Diff line number Diff line change
@@ -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] ?? {}
}
}
16 changes: 8 additions & 8 deletions tabby-local/src/shells/windowsStock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]> {
Expand Down Expand Up @@ -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(),
},
]
}
Expand Down
12 changes: 12 additions & 0 deletions tabby-settings/src/components/profilesSettingsTab.component.pug
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
(ngModelChange)='config.save()'
)

.form-line.content-box(*ngIf='hostApp.platform === Platform.Windows')
.header
.title(translate) Terminal identification
.description(translate) How Tabby presents itself through environment vars

select.form-control(
[(ngModel)]='config.store.terminal.identification',
(ngModelChange)='config.save()',
)
option(ngValue='wt', translation) Windows Terminal
option(ngValue='cygwin', translation) Cygwin

.form-line.content-box
.header
.title(translate) Default profile settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import slugify from 'slugify'
import deepClone from 'clone-deep'
import { Component, Inject } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { ConfigService, HostAppService, Profile, SelectorService, ProfilesService, PromptModalComponent, PlatformService, BaseComponent, PartialProfile, ProfileProvider, TranslateService } from 'tabby-core'
import { ConfigService, HostAppService, Profile, SelectorService, ProfilesService, PromptModalComponent, PlatformService, BaseComponent, PartialProfile, ProfileProvider, TranslateService, Platform } from 'tabby-core'
import { EditProfileModalComponent } from './editProfileModal.component'

interface ProfileGroup {
Expand All @@ -28,6 +28,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
templateProfiles: PartialProfile<Profile>[] = []
profileGroups: ProfileGroup[]
filter = ''
Platform = Platform

constructor (
public config: ConfigService,
Expand Down

0 comments on commit 842636a

Please sign in to comment.