Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tabby-electron/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NgModule } from '@angular/core'
import { PlatformService, LogService, UpdaterService, DockingService, HostAppService, ThemesService, Platform, AppService, ConfigService, WIN_BUILD_FLUENT_BG_SUPPORTED, isWindowsBuild, HostWindowService, HotkeyProvider, ConfigProvider, FileProvider } from 'tabby-core'
import { TerminalColorSchemeProvider, TerminalDecorator } from 'tabby-terminal'
import { TerminalColorSchemeProvider, TerminalContextMenuItemProvider, TerminalDecorator } from 'tabby-terminal'
import { SFTPContextMenuItemProvider, SSHProfileImporter, AutoPrivateKeyLocator } from 'tabby-ssh'

Check failure on line 4 in tabby-electron/src/index.ts

View workflow job for this annotation

GitHub Actions / Lint

Cannot find module 'tabby-ssh' or its corresponding type declarations.

Check failure on line 4 in tabby-electron/src/index.ts

View workflow job for this annotation

GitHub Actions / Linux-Build (arm, armhf, arm-unknown-linux-gnueabihf, arm-linux-gnueabihf-, ubuntu-24.04)

Cannot find module 'tabby-ssh' or its corresponding type declarations.

Check failure on line 4 in tabby-electron/src/index.ts

View workflow job for this annotation

GitHub Actions / Windows-Build (x64, x86_64-pc-windows-msvc)

Cannot find module 'tabby-ssh' or its corresponding type declarations.

Check failure on line 4 in tabby-electron/src/index.ts

View workflow job for this annotation

GitHub Actions / Linux-Build (arm64, arm64, aarch64-unknown-linux-gnu, aarch64-linux-gnu-, ubuntu-24.04-arm)

Cannot find module 'tabby-ssh' or its corresponding type declarations.

Check failure on line 4 in tabby-electron/src/index.ts

View workflow job for this annotation

GitHub Actions / macOS-Build (x86_64, x86_64-apple-darwin)

Cannot find module 'tabby-ssh' or its corresponding type declarations.

Check failure on line 4 in tabby-electron/src/index.ts

View workflow job for this annotation

GitHub Actions / macOS-Build (arm64, aarch64-apple-darwin)

Cannot find module 'tabby-ssh' or its corresponding type declarations.

Check failure on line 4 in tabby-electron/src/index.ts

View workflow job for this annotation

GitHub Actions / Windows-Build (arm64, aarch64-pc-windows-msvc)

Cannot find module 'tabby-ssh' or its corresponding type declarations.

Check failure on line 4 in tabby-electron/src/index.ts

View workflow job for this annotation

GitHub Actions / Linux-Build (x64, amd64, x86_64-unknown-linux-gnu, ubuntu-24.04)

Cannot find module 'tabby-ssh' or its corresponding type declarations.
import { PTYInterface, ShellProvider, UACService } from 'tabby-local'
import { auditTime } from 'rxjs'

Expand All @@ -21,6 +21,7 @@
import { ElectronHotkeyProvider } from './hotkeys'
import { ElectronConfigProvider } from './config'
import { EditSFTPContextMenu } from './sftpContextMenu'
import { ExportTerminalContextMenu } from './terminalContextMenu'
import { OpenSSHImporter, PrivateKeyLocator, StaticFileImporter } from './sshImporters'
import { ElectronPTYInterface } from './pty'
import { PathDropDecorator } from './pathDrop'
Expand Down Expand Up @@ -76,6 +77,8 @@

{ provide: TerminalDecorator, useClass: PathDropDecorator, multi: true },

{ provide: TerminalContextMenuItemProvider, useClass: ExportTerminalContextMenu, multi: true },

// For WindowsDefaultShellProvider
PowerShellCoreShellProvider,
WSLShellProvider,
Expand Down
44 changes: 44 additions & 0 deletions tabby-electron/src/terminalContextMenu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as fs from 'fs'
import { Injectable } from '@angular/core'
import { MenuItemOptions, NotificationsService, TranslateService } from 'tabby-core'
import { BaseTerminalTabComponent, TerminalContextMenuItemProvider } from 'tabby-terminal'
import { ElectronService } from './services/electron.service'

/** @hidden */
@Injectable()
export class ExportTerminalContextMenu extends TerminalContextMenuItemProvider {
weight = 0

constructor (
private electron: ElectronService,
private notifications: NotificationsService,
private translate: TranslateService,
) {
super()
}

async getItems (tab: BaseTerminalTabComponent<any>): Promise<MenuItemOptions[]> {
return [
{
label: this.translate.instant('Export to file'),
click: async () => {
const frontend = tab.frontend
if (!frontend) {
return
}
const result = await this.electron.dialog.showSaveDialog({
defaultPath: 'terminal.txt',
})
if (!result.filePath) {
return
}
frontend.selectAll()
const content = frontend.getSelection()
frontend.clearSelection()
await fs.promises.writeFile(result.filePath, content)
this.notifications.info(this.translate.instant('Saved to {path}', { path: result.filePath }))
},
},
]
}
}
1 change: 1 addition & 0 deletions tabby-terminal/src/tabContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,4 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
return []
}
}

Loading