mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-27 06:49:53 +00:00
cli option to launch a specific profile
This commit is contained in:
parent
fe75aab724
commit
1da7c85973
@ -13,6 +13,9 @@ export function parseArgs (argv, cwd) {
|
|||||||
.command('run [command...]', 'run a command in the terminal', {
|
.command('run [command...]', 'run a command in the terminal', {
|
||||||
command: { type: 'string' },
|
command: { type: 'string' },
|
||||||
})
|
})
|
||||||
|
.command('profile [profileName]', 'open a tab with specified profile', {
|
||||||
|
profileName: { type: 'string' },
|
||||||
|
})
|
||||||
.command('paste [text]', 'paste stdin into the active tab', yargs => {
|
.command('paste [text]', 'paste stdin into the active tab', yargs => {
|
||||||
return yargs.option('escape', {
|
return yargs.option('escape', {
|
||||||
alias: 'e',
|
alias: 'e',
|
||||||
|
@ -27,6 +27,7 @@ export class HostAppService {
|
|||||||
private cliOpenDirectory = new Subject<string>()
|
private cliOpenDirectory = new Subject<string>()
|
||||||
private cliRunCommand = new Subject<string[]>()
|
private cliRunCommand = new Subject<string[]>()
|
||||||
private cliPaste = new Subject<string>()
|
private cliPaste = new Subject<string>()
|
||||||
|
private cliOpenProfile = new Subject<string>()
|
||||||
private configChangeBroadcast = new Subject<void>()
|
private configChangeBroadcast = new Subject<void>()
|
||||||
private windowCloseRequest = new Subject<void>()
|
private windowCloseRequest = new Subject<void>()
|
||||||
private logger: Logger
|
private logger: Logger
|
||||||
@ -37,6 +38,7 @@ export class HostAppService {
|
|||||||
get cliOpenDirectory$ (): Observable<string> { return this.cliOpenDirectory }
|
get cliOpenDirectory$ (): Observable<string> { return this.cliOpenDirectory }
|
||||||
get cliRunCommand$ (): Observable<string[]> { return this.cliRunCommand }
|
get cliRunCommand$ (): Observable<string[]> { return this.cliRunCommand }
|
||||||
get cliPaste$ (): Observable<string> { return this.cliPaste }
|
get cliPaste$ (): Observable<string> { return this.cliPaste }
|
||||||
|
get cliOpenProfile$ (): Observable<string> { return this.cliOpenProfile }
|
||||||
get configChangeBroadcast$ (): Observable<void> { return this.configChangeBroadcast }
|
get configChangeBroadcast$ (): Observable<void> { return this.configChangeBroadcast }
|
||||||
get windowCloseRequest$ (): Observable<void> { return this.windowCloseRequest }
|
get windowCloseRequest$ (): Observable<void> { return this.windowCloseRequest }
|
||||||
|
|
||||||
@ -91,6 +93,8 @@ export class HostAppService {
|
|||||||
text = shellEscape([text])
|
text = shellEscape([text])
|
||||||
}
|
}
|
||||||
this.cliPaste.next(text)
|
this.cliPaste.next(text)
|
||||||
|
} else if (op === 'profile') {
|
||||||
|
this.cliOpenProfile.next(argv.profileName)
|
||||||
} else {
|
} else {
|
||||||
this.secondInstance.next()
|
this.secondInstance.next()
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,7 @@ export default class TerminalModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
hostApp.cliOpenDirectory$.subscribe(async directory => {
|
hostApp.cliOpenDirectory$.subscribe(async directory => {
|
||||||
if (await fs.exists(directory)) {
|
if (await fs.exists(directory)) {
|
||||||
if ((await fs.stat(directory)).isDirectory()) {
|
if ((await fs.stat(directory)).isDirectory()) {
|
||||||
@ -172,6 +173,7 @@ export default class TerminalModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
hostApp.cliRunCommand$.subscribe(async command => {
|
hostApp.cliRunCommand$.subscribe(async command => {
|
||||||
terminal.openTab({
|
terminal.openTab({
|
||||||
id: '',
|
id: '',
|
||||||
@ -180,6 +182,7 @@ export default class TerminalModule {
|
|||||||
}, null, true)
|
}, null, true)
|
||||||
hostApp.bringToFront()
|
hostApp.bringToFront()
|
||||||
})
|
})
|
||||||
|
|
||||||
hostApp.cliPaste$.subscribe(text => {
|
hostApp.cliPaste$.subscribe(text => {
|
||||||
if (app.activeTab instanceof TerminalTabComponent && app.activeTab.session) {
|
if (app.activeTab instanceof TerminalTabComponent && app.activeTab.session) {
|
||||||
(app.activeTab as TerminalTabComponent).sendInput(text)
|
(app.activeTab as TerminalTabComponent).sendInput(text)
|
||||||
@ -187,6 +190,16 @@ export default class TerminalModule {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
hostApp.cliOpenProfile$.subscribe(async profileName => {
|
||||||
|
let profile = config.store.terminal.profiles.find(x => x.name === profileName)
|
||||||
|
if (!profile) {
|
||||||
|
console.error('Requested profile', profileName, 'not found')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
terminal.openTabWithOptions(profile.sessionOptions)
|
||||||
|
hostApp.bringToFront()
|
||||||
|
})
|
||||||
|
|
||||||
dockMenu.update()
|
dockMenu.update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user