mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-04 14:04:56 +00:00
done
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "webpack --progress --color",
|
||||
"build": "webpack --progress --color --display-modules",
|
||||
"watch": "webpack --progress --color --watch"
|
||||
},
|
||||
"author": "Eugene Pankov",
|
||||
@@ -16,25 +16,30 @@
|
||||
"@types/webpack-env": "1.13.0",
|
||||
"awesome-typescript-loader": "3.1.2",
|
||||
"css-loader": "^0.28.0",
|
||||
"dataurl": "0.1.0",
|
||||
"deep-equal": "1.0.1",
|
||||
"pug": "^2.0.0-beta11",
|
||||
"pug-loader": "^2.3.0",
|
||||
"raw-loader": "^0.5.1",
|
||||
"sass-loader": "^6.0.3",
|
||||
"style-loader": "^0.16.1",
|
||||
"to-string-loader": "^1.1.5",
|
||||
"webpack": "2.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"peerDependencies": {
|
||||
"@angular/common": "4.0.1",
|
||||
"@angular/core": "4.0.1",
|
||||
"@angular/forms": "4.0.1",
|
||||
"@angular/platform-browser": "4.0.1",
|
||||
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.22",
|
||||
"child-process-promise": "2.2.1",
|
||||
"dataurl": "0.1.0",
|
||||
"deep-equal": "1.0.1",
|
||||
"fs-promise": "2.0.2",
|
||||
"hterm-commonjs": "1.0.0",
|
||||
"node-pty": "0.6.2",
|
||||
"terminus-core": "*",
|
||||
"terminus-settings": "*",
|
||||
"rxjs": "5.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"child-process-promise": "2.2.1",
|
||||
"fs-promise": "2.0.2",
|
||||
"font-manager": "0.2.2",
|
||||
"hterm-commonjs": "1.0.0",
|
||||
"node-pty": "0.6.2"
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { HotkeysService, ToolbarButtonProvider, IToolbarButton, AppService } from 'terminus-core'
|
||||
import { HotkeysService, ToolbarButtonProvider, IToolbarButton, AppService, HostAppService, Platform } from 'terminus-core'
|
||||
|
||||
import { SessionsService } from './services/sessions'
|
||||
import { TerminalTabComponent } from './components/terminalTab'
|
||||
@@ -10,6 +10,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
constructor (
|
||||
private app: AppService,
|
||||
private sessions: SessionsService,
|
||||
private hostApp: HostAppService,
|
||||
hotkeys: HotkeysService,
|
||||
) {
|
||||
super()
|
||||
@@ -25,9 +26,14 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
if (this.app.activeTab instanceof TerminalTabComponent) {
|
||||
cwd = await this.app.activeTab.session.getWorkingDirectory()
|
||||
}
|
||||
let command = {
|
||||
[Platform.macOS]: 'zsh',
|
||||
[Platform.Linux]: 'zsh',
|
||||
[Platform.Windows]: 'cmd.exe',
|
||||
}[this.hostApp.platform]
|
||||
this.app.openNewTab(
|
||||
TerminalTabComponent,
|
||||
{ session: await this.sessions.createNewSession({ command: 'zsh', cwd }) }
|
||||
{ session: await this.sessions.createNewSession({ command, cwd }) }
|
||||
)
|
||||
}
|
||||
|
@@ -43,6 +43,12 @@
|
||||
span ->
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[1]') link
|
||||
div
|
||||
span
|
||||
div
|
||||
span john@doe-pc
|
||||
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
|
||||
span rm -rf /
|
||||
span([style.background-color]='config.full().terminal.colorScheme.cursor')
|
||||
|
||||
|
||||
.col-lg-6
|
||||
@@ -85,7 +91,7 @@
|
||||
title='BG',
|
||||
)
|
||||
color-picker(
|
||||
'[(model)]'='config.store.terminal.cursor.background',
|
||||
'[(model)]'='config.store.terminal.colorScheme.cursor',
|
||||
(modelChange)='config.save()',
|
||||
title='CU',
|
||||
)
|
@@ -3,8 +3,10 @@ import 'rxjs/add/operator/map'
|
||||
import 'rxjs/add/operator/debounceTime'
|
||||
import 'rxjs/add/operator/distinctUntilChanged'
|
||||
const equal = require('deep-equal')
|
||||
const fontManager = require('font-manager')
|
||||
|
||||
import { Component, Inject } from '@angular/core'
|
||||
import { ConfigService } from 'terminus-core'
|
||||
import { ConfigService, HostAppService, Platform } from 'terminus-core'
|
||||
const { exec } = require('child-process-promise')
|
||||
|
||||
import { TerminalColorSchemeProvider, ITerminalColorScheme } from '../api'
|
||||
@@ -21,19 +23,26 @@ export class SettingsComponent {
|
||||
|
||||
constructor(
|
||||
public config: ConfigService,
|
||||
private hostApp: HostAppService,
|
||||
@Inject(TerminalColorSchemeProvider) private colorSchemeProviders: TerminalColorSchemeProvider[],
|
||||
) { }
|
||||
|
||||
async ngOnInit () {
|
||||
exec('fc-list :spacing=mono').then((result) => {
|
||||
this.fonts = result.stdout
|
||||
.split('\n')
|
||||
.filter((x) => !!x)
|
||||
.map((x) => x.split(':')[1].trim())
|
||||
.map((x) => x.split(',')[0].trim())
|
||||
if (this.hostApp.platform == Platform.Windows) {
|
||||
let fonts = await new Promise<any[]>((resolve) => fontManager.findFonts({ monospace: true }, resolve))
|
||||
this.fonts = fonts.map(x => x.family)
|
||||
this.fonts.sort()
|
||||
})
|
||||
|
||||
}
|
||||
if (this.hostApp.platform == Platform.Linux) {
|
||||
exec('fc-list :spacing=mono').then((result) => {
|
||||
this.fonts = result.stdout
|
||||
.split('\n')
|
||||
.filter(x => !!x)
|
||||
.map(x => x.split(':')[1].trim())
|
||||
.map(x => x.split(',')[0].trim())
|
||||
this.fonts.sort()
|
||||
})
|
||||
}
|
||||
this.colorSchemes = (await Promise.all(this.colorSchemeProviders.map(x => x.getSchemes()))).reduce((a, b) => a.concat(b))
|
||||
}
|
||||
|
@@ -12,7 +12,8 @@ export class TerminalConfigProvider extends ConfigProvider {
|
||||
colorScheme: {
|
||||
foreground: null,
|
||||
background: null,
|
||||
colors: null,
|
||||
cursor: null,
|
||||
colors: [],
|
||||
},
|
||||
},
|
||||
hotkeys: {
|
@@ -3,7 +3,7 @@ import { BrowserModule } from '@angular/platform-browser'
|
||||
import { FormsModule } from '@angular/forms'
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||
|
||||
import { ToolbarButtonProvider, TabRecoveryProvider, ConfigProvider, HotkeysService } from 'terminus-core'
|
||||
import { HostAppService, Platform, ToolbarButtonProvider, TabRecoveryProvider, ConfigProvider, HotkeysService } from 'terminus-core'
|
||||
import { SettingsTabProvider } from 'terminus-settings'
|
||||
|
||||
import { TerminalTabComponent } from './components/terminalTab'
|
||||
@@ -28,10 +28,20 @@ import { hterm } from './hterm'
|
||||
],
|
||||
providers: [
|
||||
SessionsService,
|
||||
ScreenPersistenceProvider,
|
||||
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
|
||||
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true },
|
||||
{ provide: SessionPersistenceProvider, useClass: ScreenPersistenceProvider },
|
||||
// { provide: SessionPersistenceProvider, useValue: null },
|
||||
{
|
||||
provide: SessionPersistenceProvider,
|
||||
useFactory: (hostApp: HostAppService, screen: ScreenPersistenceProvider) => {
|
||||
if (hostApp.platform == Platform.Windows) {
|
||||
return null
|
||||
} else {
|
||||
return screen
|
||||
}
|
||||
},
|
||||
deps: [HostAppService, ScreenPersistenceProvider],
|
||||
},
|
||||
{ provide: SettingsTabProvider, useClass: TerminalSettingsProvider, multi: true },
|
||||
{ provide: ConfigProvider, useClass: TerminalConfigProvider, multi: true },
|
||||
{ provide: TerminalColorSchemeProvider, useClass: HyperColorSchemes, multi: true },
|
@@ -6,7 +6,12 @@ import { SessionOptions, SessionPersistenceProvider } from './api'
|
||||
|
||||
export class ScreenPersistenceProvider extends SessionPersistenceProvider {
|
||||
async attachSession (recoveryId: any): Promise<SessionOptions> {
|
||||
let lines = (await exec('screen -list')).stdout.split('\n')
|
||||
let lines: string[]
|
||||
try {
|
||||
lines = (await exec('screen -list')).stdout.split('\n')
|
||||
} catch (result) {
|
||||
lines = result.stdout.split('\n')
|
||||
}
|
||||
let screenPID = lines
|
||||
.filter(line => line.indexOf('.' + recoveryId) !== -1)
|
||||
.map(line => parseInt(line.trim().split('.')[0]))[0]
|
||||
@@ -15,8 +20,8 @@ export class ScreenPersistenceProvider extends SessionPersistenceProvider {
|
||||
return null
|
||||
}
|
||||
|
||||
lines = (await exec(`ps -o pid --ppid ${screenPID}`)).stdout.split('\n')
|
||||
let recoveredTruePID = parseInt(lines[1].split(/\s/).filter(x => !!x)[0])
|
||||
lines = (await exec(`pgrep -P ${screenPID}`)).stdout.split('\n')
|
||||
let recoveredTruePID = parseInt(lines[0])
|
||||
|
||||
return {
|
||||
recoveryId,
|
||||
@@ -30,7 +35,7 @@ export class ScreenPersistenceProvider extends SessionPersistenceProvider {
|
||||
let configPath = '/tmp/.termScreenConfig'
|
||||
await fs.writeFile(configPath, `
|
||||
escape ^^^
|
||||
vbell off
|
||||
vbell on
|
||||
term xterm-color
|
||||
bindkey "^[OH" beginning-of-line
|
||||
bindkey "^[OF" end-of-line
|
@@ -3,6 +3,7 @@ import * as fs from 'fs-promise'
|
||||
import { Subject } from 'rxjs'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { Logger, LogService } from 'terminus-core'
|
||||
const { exec } = require('child-process-promise')
|
||||
|
||||
import { SessionOptions, SessionPersistenceProvider } from '../api'
|
||||
|
||||
@@ -112,7 +113,14 @@ export class Session {
|
||||
}
|
||||
|
||||
async getWorkingDirectory (): Promise<string> {
|
||||
return await fs.readlink(`/proc/${this.truePID}/cwd`)
|
||||
if (process.platform == 'darwin') {
|
||||
let lines = (await exec(`lsof -p ${this.truePID} -Fn`)).split('\n')
|
||||
return lines[2]
|
||||
}
|
||||
if (process.platform == 'linux') {
|
||||
return await fs.readlink(`/proc/${this.truePID}/cwd`)
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"baseUrl": "src",
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"declaration": false,
|
||||
@@ -22,7 +22,8 @@
|
||||
"es7"
|
||||
],
|
||||
"paths": {
|
||||
"terminus-*": ["../terminus-*"]
|
||||
"*": ["../../app/node_modules/*"],
|
||||
"terminus-*": ["../../terminus-*"]
|
||||
}
|
||||
},
|
||||
"compileOnSave": false,
|
||||
|
@@ -1,15 +1,15 @@
|
||||
module.exports = {
|
||||
target: 'node',
|
||||
entry: 'index.ts',
|
||||
entry: 'src/index.ts',
|
||||
devtool: 'source-map',
|
||||
output: {
|
||||
filename: './dist/index.js',
|
||||
pathinfo: true,
|
||||
library: 'terminusTerminal',
|
||||
libraryTarget: 'umd',
|
||||
devtoolModuleFilenameTemplate: 'webpack-terminus-terminal:///[resource-path]',
|
||||
},
|
||||
resolve: {
|
||||
modules: ['.', 'node_modules', '..'],
|
||||
modules: ['.', 'node_modules', '../app/node_modules'],
|
||||
extensions: ['.ts', '.js'],
|
||||
},
|
||||
module: {
|
||||
@@ -17,19 +17,20 @@ module.exports = {
|
||||
{ test: /\.ts$/, use: 'awesome-typescript-loader' },
|
||||
{ test: /schemes\/.*$/, use: "raw-loader" },
|
||||
{ test: /\.pug$/, use: ['apply-loader', 'pug-loader'] },
|
||||
{ test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
|
||||
{ test: /\.css$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
|
||||
{ test: /\.scss$/, use: ['to-string-loader', 'css-loader', 'sass-loader'] },
|
||||
{ test: /\.css$/, use: ['to-string-loader', 'css-loader', 'sass-loader'] },
|
||||
]
|
||||
},
|
||||
externals: {
|
||||
'fs': true,
|
||||
'fs-promise': true,
|
||||
'path': true,
|
||||
'node-pty': true,
|
||||
'child-process-promise': true,
|
||||
'fs-promise': true,
|
||||
'@angular/core': true,
|
||||
'terminus-core': true,
|
||||
'terminus-settings': true,
|
||||
}
|
||||
externals: [
|
||||
'fs',
|
||||
'fs-promise',
|
||||
'font-manager',
|
||||
'path',
|
||||
'node-pty',
|
||||
'child-process-promise',
|
||||
/^rxjs/,
|
||||
/^@angular/,
|
||||
/^@ng-bootstrap/,
|
||||
/^terminus-/,
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user