diff --git a/terminus-terminal/src/services/terminal.service.ts b/terminus-terminal/src/services/terminal.service.ts index 7e52b083..ab8d90d9 100644 --- a/terminus-terminal/src/services/terminal.service.ts +++ b/terminus-terminal/src/services/terminal.service.ts @@ -63,15 +63,18 @@ export class TerminalService { * @param pause Wait for a keypress when the shell exits */ async openTab (profile?: Profile, cwd?: string, pause?: boolean): Promise { - cwd = cwd || profile.sessionOptions.cwd - if (cwd && !fs.existsSync(cwd)) { - console.warn('Ignoring non-existent CWD:', cwd) - cwd = null - } if (!profile) { let profiles = await this.getProfiles() profile = profiles.find(x => slug(x.name) === this.config.store.terminal.profile) || profiles[0] } + + cwd = cwd || profile.sessionOptions.cwd + + if (cwd && !fs.existsSync(cwd)) { + console.warn('Ignoring non-existent CWD:', cwd) + cwd = null + } + if (!cwd) { if (this.app.activeTab instanceof TerminalTabComponent && this.app.activeTab.session) { cwd = await this.app.activeTab.session.getWorkingDirectory()