autoselect tmux

This commit is contained in:
Eugene Pankov 2017-07-27 12:54:51 +02:00
parent 23dabca2ab
commit c0c2b693f3
2 changed files with 19 additions and 1 deletions

View File

@ -48,7 +48,12 @@ import { hterm } from './hterm'
if (hostApp.platform === Platform.Windows) {
return null
} else {
return tmux
if (tmux.isAvailable()) {
tmux.init()
return tmux
} else {
return screen
}
}
},
deps: [HostAppService, ScreenPersistenceProvider, TMuxPersistenceProvider],

View File

@ -1,4 +1,5 @@
import { Injectable } from '@angular/core'
import { execFileSync } from 'child_process'
import * as AsyncLock from 'async-lock'
import { ConnectableObservable, Subject } from 'rxjs'
import * as childProcess from 'child_process'
@ -166,6 +167,18 @@ export class TMuxPersistenceProvider extends SessionPersistenceProvider {
constructor () {
super()
}
isAvailable (): boolean {
try {
execFileSync('tmux', ['-V'])
return true
} catch (_) {
return false
}
}
init () {
this.tmux = new TMux()
}