From c0c2b693f339e24afcb995ed36e0d35e39d89a5a Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Thu, 27 Jul 2017 12:54:51 +0200 Subject: [PATCH] autoselect tmux --- terminus-terminal/src/index.ts | 7 ++++++- terminus-terminal/src/tmux.ts | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/terminus-terminal/src/index.ts b/terminus-terminal/src/index.ts index fbd77337..ac205528 100644 --- a/terminus-terminal/src/index.ts +++ b/terminus-terminal/src/index.ts @@ -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], diff --git a/terminus-terminal/src/tmux.ts b/terminus-terminal/src/tmux.ts index 283366ee..46ac25a6 100644 --- a/terminus-terminal/src/tmux.ts +++ b/terminus-terminal/src/tmux.ts @@ -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() }