suggest WSL root path as working directory (#454)

This commit is contained in:
Eugene Pankov
2018-10-13 19:09:50 +02:00
parent 144798a336
commit 8881b835b4
3 changed files with 25 additions and 8 deletions

View File

@@ -41,9 +41,13 @@ h3.mb-3 Shell
.form-line
.header
.title Working directory
input.form-control(
type='text',
placeholder='Home directory',
[(ngModel)]='config.store.terminal.workingDirectory',
(ngModelChange)='config.save()',
)
.input-group
input.form-control(
type='text',
placeholder='Home directory',
[(ngModel)]='config.store.terminal.workingDirectory',
(ngModelChange)='config.save()',
)
.input-group-btn
button.btn.btn-secondary((click)='pickWorkingDirectory()')
i.fa.fa-folder-open

View File

@@ -1,5 +1,5 @@
import { Component, Inject } from '@angular/core'
import { ConfigService } from 'terminus-core'
import { ConfigService, ElectronService } from 'terminus-core'
import { IShell, ShellProvider, SessionPersistenceProvider } from '../api'
@Component({
@@ -11,6 +11,7 @@ export class ShellSettingsTabComponent {
constructor (
public config: ConfigService,
private electron: ElectronService,
@Inject(ShellProvider) private shellProviders: ShellProvider[],
@Inject(SessionPersistenceProvider) persistenceProviders: SessionPersistenceProvider[],
) {
@@ -20,4 +21,16 @@ export class ShellSettingsTabComponent {
async ngOnInit () {
this.shells = (await Promise.all(this.config.enabledServices(this.shellProviders).map(x => x.provide()))).reduce((a, b) => a.concat(b))
}
pickWorkingDirectory () {
let shell = this.shells.find(x => x.id === this.config.store.terminal.shell)
console.log(shell)
let paths = this.electron.dialog.showOpenDialog({
defaultPath: shell.fsBase,
properties: ['openDirectory', 'showHiddenFiles'],
})
if (paths) {
this.config.store.terminal.workingDirectory = paths[0]
}
}
}

View File

@@ -57,7 +57,7 @@ export class WSLShellProvider extends ShellProvider {
name: `WSL / ${name}`,
command: wslPath,
args: ['-d', name],
fsBase: (child as any).$values.basepath,
fsBase: (child as any).$values.basepath + '\\rootfs',
env: {
TERM: 'xterm-color',
COLORTERM: 'truecolor',