From b7ac65fce09903693418f2e61b303e2f86a46bce Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Thu, 2 Sep 2021 23:52:31 +0200 Subject: [PATCH] added msys2 built-in profiles - fixes #2962 --- tabby-local/src/icons/msys2.svg | 25 +++++++++++++++++++++ tabby-local/src/index.ts | 2 ++ tabby-local/src/shells/msys2.ts | 40 +++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 tabby-local/src/icons/msys2.svg create mode 100644 tabby-local/src/shells/msys2.ts diff --git a/tabby-local/src/icons/msys2.svg b/tabby-local/src/icons/msys2.svg new file mode 100644 index 00000000..fe12b4eb --- /dev/null +++ b/tabby-local/src/icons/msys2.svg @@ -0,0 +1,25 @@ + + + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/tabby-local/src/index.ts b/tabby-local/src/index.ts index ef3f7d0b..1d2a81ce 100644 --- a/tabby-local/src/index.ts +++ b/tabby-local/src/index.ts @@ -32,6 +32,7 @@ import { Cygwin64ShellProvider } from './shells/cygwin64' import { GitBashShellProvider } from './shells/gitBash' import { LinuxDefaultShellProvider } from './shells/linuxDefault' import { MacOSDefaultShellProvider } from './shells/macDefault' +import { MSYS2ShellProvider } from './shells/msys2' import { POSIXShellsProvider } from './shells/posix' import { PowerShellCoreShellProvider } from './shells/powershellCore' import { WindowsDefaultShellProvider } from './shells/winDefault' @@ -71,6 +72,7 @@ import { LocalProfilesService } from './profiles' { provide: ShellProvider, useClass: Cygwin64ShellProvider, multi: true }, { provide: ShellProvider, useClass: GitBashShellProvider, multi: true }, { provide: ShellProvider, useClass: POSIXShellsProvider, multi: true }, + { provide: ShellProvider, useClass: MSYS2ShellProvider, multi: true }, { provide: ShellProvider, useClass: WSLShellProvider, multi: true }, { provide: ShellProvider, useClass: VSDevToolsProvider, multi: true }, diff --git a/tabby-local/src/shells/msys2.ts b/tabby-local/src/shells/msys2.ts new file mode 100644 index 00000000..3cee0ac9 --- /dev/null +++ b/tabby-local/src/shells/msys2.ts @@ -0,0 +1,40 @@ +import * as fs from 'fs/promises' +import * as path from 'path' +import { Injectable } from '@angular/core' +import { HostAppService, Platform } from 'tabby-core' + +import { ShellProvider, Shell } from '../api' + +/** @hidden */ +@Injectable() +export class MSYS2ShellProvider extends ShellProvider { + constructor ( + private hostApp: HostAppService, + ) { + super() + } + + async provide (): Promise { + if (this.hostApp.platform !== Platform.Windows) { + return [] + } + + const msys2Path = path.resolve(process.env.SystemRoot ?? 'C:\\Windows', '../msys64') + try { + await fs.access(msys2Path) + } catch { + return [] + } + + const environments = ['msys', 'mingw64', 'clang64', 'ucrt64'] + + return environments.map(e => ({ + id: `msys2-${e}`, + name: `MSYS2 (${e.toUpperCase()})`, + command: path.join(msys2Path, 'msys2_shell.cmd'), + args: ['-defterm', '-here', '-no-start', '-' + e], + icon: require('../icons/msys2.svg'), + env: {}, + })) + } +}