From 2848f9f2573e8c1f7ea8c84d80ba4e4875254c73 Mon Sep 17 00:00:00 2001 From: Austin Warren Date: Wed, 24 Jul 2019 11:56:57 -0700 Subject: [PATCH 1/2] Added ability to configure whether new terminals will always open with the configured working directory --- .../components/shellSettingsTab.component.pug | 10 ++++++++++ terminus-terminal/src/config.ts | 1 + terminus-terminal/src/contextMenu.ts | 4 +++- .../src/services/terminal.service.ts | 16 +++++++++------- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/terminus-terminal/src/components/shellSettingsTab.component.pug b/terminus-terminal/src/components/shellSettingsTab.component.pug index f858e363..06aa5640 100644 --- a/terminus-terminal/src/components/shellSettingsTab.component.pug +++ b/terminus-terminal/src/components/shellSettingsTab.component.pug @@ -55,6 +55,16 @@ h3.mb-3 Shell button.btn.btn-secondary((click)='pickWorkingDirectory()') i.fas.fa-folder-open +.form-line + .header + .title Always Use Working Directory + .description By default, new terminals will open where the previous terminal was working. Enabling this option will always launch new terminals in the working directory specified above. + + toggle( + [(ngModel)]='config.store.terminal.alwaysUseWorkingDirectory', + (ngModelChange)='config.save()' + ) + .form-line.align-items-start .header .title Environment diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index c86cc500..280bab20 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -27,6 +27,7 @@ export class TerminalConfigProvider extends ConfigProvider { copyOnSelect: false, scrollOnInput: true, workingDirectory: '', + alwaysUseWorkingDirectory: false, altIsMeta: false, colorScheme: { __nonStructural: true, diff --git a/terminus-terminal/src/contextMenu.ts b/terminus-terminal/src/contextMenu.ts index 051c8773..b83274a0 100644 --- a/terminus-terminal/src/contextMenu.ts +++ b/terminus-terminal/src/contextMenu.ts @@ -35,7 +35,9 @@ export class NewTabContextMenu extends TerminalContextMenuItemProvider { submenu: profiles.map(profile => ({ label: profile.name, click: () => this.zone.run(async () => { - this.terminalService.openTab(profile, await tab.session.getWorkingDirectory()) + const workingDirectory = this.config.store.terminal.alwaysUseWorkingDirectory ? + this.config.store.terminal.workingDirectory : await tab.session.getWorkingDirectory(); + this.terminalService.openTab(profile, workingDirectory); }), })), }, diff --git a/terminus-terminal/src/services/terminal.service.ts b/terminus-terminal/src/services/terminal.service.ts index ee551822..9d156005 100644 --- a/terminus-terminal/src/services/terminal.service.ts +++ b/terminus-terminal/src/services/terminal.service.ts @@ -65,14 +65,16 @@ export class TerminalService { } if (!cwd) { - if (this.app.activeTab instanceof TerminalTabComponent && this.app.activeTab.session) { - cwd = await this.app.activeTab.session.getWorkingDirectory() - } - if (this.app.activeTab instanceof SplitTabComponent) { - const focusedTab = this.app.activeTab.getFocusedTab() + if (!this.config.store.terminal.alwaysUseWorkingDirectory) { + if (this.app.activeTab instanceof TerminalTabComponent && this.app.activeTab.session) { + cwd = await this.app.activeTab.session.getWorkingDirectory() + } + if (this.app.activeTab instanceof SplitTabComponent) { + const focusedTab = this.app.activeTab.getFocusedTab() - if (focusedTab instanceof TerminalTabComponent && focusedTab.session) { - cwd = await focusedTab.session.getWorkingDirectory() + if (focusedTab instanceof TerminalTabComponent && focusedTab.session) { + cwd = await focusedTab.session.getWorkingDirectory() + } } } cwd = cwd || this.config.store.terminal.workingDirectory From 2acda3be5f840fd5dadff93a9a0c6337c3021eef Mon Sep 17 00:00:00 2001 From: Austin Warren Date: Wed, 24 Jul 2019 17:09:08 -0700 Subject: [PATCH 2/2] fix lint --- terminus-terminal/src/contextMenu.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/terminus-terminal/src/contextMenu.ts b/terminus-terminal/src/contextMenu.ts index b83274a0..7e5fe089 100644 --- a/terminus-terminal/src/contextMenu.ts +++ b/terminus-terminal/src/contextMenu.ts @@ -35,9 +35,9 @@ export class NewTabContextMenu extends TerminalContextMenuItemProvider { submenu: profiles.map(profile => ({ label: profile.name, click: () => this.zone.run(async () => { - const workingDirectory = this.config.store.terminal.alwaysUseWorkingDirectory ? - this.config.store.terminal.workingDirectory : await tab.session.getWorkingDirectory(); - this.terminalService.openTab(profile, workingDirectory); + const workingDirectory = this.config.store.terminal.alwaysUseWorkingDirectory === true ? + this.config.store.terminal.workingDirectory : await tab.session.getWorkingDirectory() + await this.terminalService.openTab(profile, workingDirectory) }), })), },