mirror of
https://github.com/Eugeny/tabby.git
synced 2024-11-22 11:52:03 +03:00
This commit is contained in:
parent
509ae8d32e
commit
296188c45e
@ -1,7 +1,7 @@
|
||||
import * as path from 'path'
|
||||
import * as fs from 'mz/fs'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { CLIHandler, CLIEvent, AppService, ConfigService, HostWindowService } from 'tabby-core'
|
||||
import { CLIHandler, CLIEvent, AppService, ConfigService, HostWindowService, ProfilesService, NotificationsService } from 'tabby-core'
|
||||
import { TerminalService } from './services/terminal.service'
|
||||
|
||||
@Injectable()
|
||||
@ -63,7 +63,9 @@ export class OpenPathCLIHandler extends CLIHandler {
|
||||
|
||||
constructor (
|
||||
private terminal: TerminalService,
|
||||
private profiles: ProfilesService,
|
||||
private hostWindow: HostWindowService,
|
||||
private notifications: NotificationsService,
|
||||
) {
|
||||
super()
|
||||
}
|
||||
@ -72,12 +74,44 @@ export class OpenPathCLIHandler extends CLIHandler {
|
||||
const op = event.argv._[0]
|
||||
const opAsPath = op ? path.resolve(event.cwd, op) : null
|
||||
|
||||
const profile = await this.terminal.getDefaultProfile()
|
||||
|
||||
if (opAsPath && (await fs.lstat(opAsPath)).isDirectory()) {
|
||||
this.terminal.openTab(undefined, opAsPath)
|
||||
this.terminal.openTab(profile, opAsPath)
|
||||
this.hostWindow.bringToFront()
|
||||
return true
|
||||
}
|
||||
|
||||
if (opAsPath && await fs.exists(opAsPath)) {
|
||||
if (opAsPath.endsWith('.sh') || opAsPath.endsWith('.command')) {
|
||||
profile.options!.pauseAfterExit = true
|
||||
profile.options?.args?.push(opAsPath)
|
||||
this.terminal.openTab(profile)
|
||||
this.hostWindow.bringToFront()
|
||||
return true
|
||||
} else if (opAsPath.endsWith('.bat')) {
|
||||
const psProfile = (await this.profiles.getProfiles()).find(x => x.id === 'cmd')
|
||||
if (psProfile) {
|
||||
psProfile.options!.pauseAfterExit = true
|
||||
psProfile.options?.args?.push(opAsPath)
|
||||
this.terminal.openTab(psProfile)
|
||||
this.hostWindow.bringToFront()
|
||||
return true
|
||||
}
|
||||
} else if (opAsPath.endsWith('.ps1')) {
|
||||
const cmdProfile = (await this.profiles.getProfiles()).find(x => x.id === 'powershell')
|
||||
if (cmdProfile) {
|
||||
cmdProfile.options!.pauseAfterExit = true
|
||||
cmdProfile.options?.args?.push(opAsPath)
|
||||
this.terminal.openTab(cmdProfile)
|
||||
this.hostWindow.bringToFront()
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
this.notifications.error('Cannot handle scripts of this type')
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ export class TerminalService {
|
||||
this.logger.info(`Starting profile ${fullProfile.name}`, fullProfile)
|
||||
const options = {
|
||||
...fullProfile.options,
|
||||
pauseAfterExit: pause,
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
pauseAfterExit: fullProfile.options.pauseAfterExit || pause,
|
||||
cwd: cwd ?? undefined,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user