Compare commits

...

17 Commits

Author SHA1 Message Date
Eugene Pankov
0e9282e079 docs 2017-07-01 14:13:07 +02:00
Eugene Pankov
5511f4d7cb docs fix 2017-07-01 14:03:14 +02:00
Eugene Pankov
3ae76e66ed Merge branch 'master' of github.com:Eugeny/terminus 2017-07-01 12:48:48 +02:00
Eugene Pankov
42059e3bc6 Create CODE_OF_CONDUCT.md 2017-07-01 10:54:04 +02:00
Eugene Pankov
c093b204d7 override plugin module resolution 2017-07-01 01:22:01 +02:00
Eugene Pankov
8a8f89b386 wip 2017-07-01 00:55:21 +02:00
Eugene Pankov
b109fb8766 plugin versions 2017-07-01 00:54:55 +02:00
Eugene Pankov
f58cf469ed Linux default shell fix 2017-06-30 21:20:03 +02:00
Eugene Pankov
57227ae6ce Merge branch 'master' of github.com:Eugeny/terminus 2017-06-30 21:08:19 +02:00
Eugene Pankov
b670fa843a don't force electron-debug 2017-06-30 21:08:12 +02:00
Eugene Pankov
c41e551c58 README update 2017-06-30 20:59:23 +02:00
Eugene Pankov
60b02b17e4 Start shell as login shell (fixes #2) 2017-06-30 20:52:22 +02:00
Eugene Pankov
bf8bb7ee80 use user's default shell (#2) 2017-06-30 20:44:17 +02:00
Eugene Pankov
1e1d48a5f8 rollback 2017-06-30 20:01:41 +02:00
Eugene Pankov
77b55a003c Git-bash support (fixes #12) 2017-06-30 19:54:17 +02:00
Eugene Pankov
165ab1cfbf version mgmt 2017-06-30 19:40:18 +02:00
Eugene Pankov
d4840bafaf Some docking fixes (fixed #13) 2017-06-30 19:39:01 +02:00
24 changed files with 210 additions and 61 deletions

46
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at e@ajenti.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@@ -67,7 +67,11 @@ terminus-pluginname
# Plugins
The app will load all plugins from the source checkout in the dev mode, and from the user's plugins directory at all times (click `Open Plugins Directory` under `Settings` > `Plugins`).
The app will load all plugins from the source checkout in the dev mode, from the user's plugins directory at all times (click `Open Plugins Directory` under `Settings` > `Plugins`) and from the directory specified by the `TERMINUS_PLUGINS` environment var.
Only modules whose `package.json` file contains a `terminus-plugin` keyword will be loaded.
If you're currently in your plugin's directory, start Terminus as `TERMINUS_PLUGINS=$(pwd) terminus --debug`
A plugin should only provide a default export, which should be a `NgModule` class (or a `NgModuleWithDependencies` where applicable). This module will be injected as a dependency to the app's root module.

View File

@@ -17,7 +17,16 @@
* Doesn't choke on fast-flowing outputs
* Tab persistence on macOS and Linux
* Proper shell-like experience on Windows including tab completion (thanks, Clink!)
* CMD, PowerShell and Bash on Windows support
* CMD, PowerShell, Cygwin, Git-Bash and Bash on Windows support
---
# Plugins
Plugins can be installed directly from the Settings view inside Terminus.
* [clickable-links](https://github.com/Eugeny/terminus-clickable-links) - makes paths and URLs in the terminal clickable
* [theme-hype](https://github.com/Eugeny/terminus-theme-hype) - a Hyper inspired theme
---
@@ -25,4 +34,4 @@
Pull requests and plugins are welcome! Publish your plugin on NPM with a `terminus-plugin` keyword to make them appear in the Plugin Manager.
See [HACKING.md](https://github.com/Eugeny/terminus/blob/master/HACKING.md) for a very plugin development tutorial!
See [HACKING.md](https://github.com/Eugeny/terminus/blob/master/HACKING.md) for a very brief plugin development tutorial!

View File

@@ -22,7 +22,6 @@ const yaml = require('js-yaml')
const path = require('path')
const fs = require('fs')
const Config = require('electron-config')
require('electron-debug')({enabled: true, showDevTools: process.argv.indexOf('--debug') != -1})
let windowConfig = new Config({name: 'window'})

View File

@@ -1,4 +1,4 @@
import 'zone.js/dist/zone.js'
import 'zone.js'
import 'core-js/es7/reflect'
import 'core-js/core/delay'
import 'rxjs'

View File

@@ -20,11 +20,7 @@ if (process.env.DEV) {
nodeModule.globalPaths.unshift(path.dirname(require('electron').remote.app.getAppPath()))
}
const builtinPluginsPath = path.join(
path.dirname(require('electron').remote.app.getPath('exe')),
(process.platform === 'darwin') ? '../Resources' : 'resources',
'builtin-plugins',
)
const builtinPluginsPath = path.join((process as any).resourcesPath, 'builtin-plugins')
const userPluginsPath = path.join(
require('electron').remote.app.getPath('appData'),
@@ -35,9 +31,9 @@ const userPluginsPath = path.join(
Object.assign(window, { builtinPluginsPath, userPluginsPath })
nodeModule.globalPaths.unshift(builtinPluginsPath)
nodeModule.globalPaths.unshift(path.join(userPluginsPath, 'node_modules'))
// nodeModule.globalPaths.unshift(path.join((process as any).resourcesPath, 'app.asar', 'node_modules'))
if (process.env.TERMINUS_PLUGINS) {
process.env.TERMINUS_PLUGINS.split(':').map(x => nodeModule.globalPaths.unshift(normalizePath(x)))
process.env.TERMINUS_PLUGINS.split(':').map(x => nodeModule.globalPaths.push(normalizePath(x)))
}
export declare type ProgressCallback = (current, total) => void
@@ -53,9 +49,39 @@ export interface IPluginInfo {
info?: any
}
const builtinModules = [
'@angular/animations',
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/forms',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@ng-bootstrap/ng-bootstrap',
'rxjs',
'terminus-core',
'terminus-settings',
'terminus-terminal',
'zone.js/dist/zone.js',
]
const cachedBuiltinModules = {}
builtinModules.forEach(m => {
cachedBuiltinModules[m] = nodeRequire(m)
})
const originalRequire = nodeRequire('module').prototype.require
nodeRequire('module').prototype.require = function (query) {
if (cachedBuiltinModules[query]) {
return cachedBuiltinModules[query]
}
return originalRequire.apply(this, arguments)
}
export async function findPlugins (): Promise<IPluginInfo[]> {
let paths = nodeModule.globalPaths
let foundPlugins: IPluginInfo[] = []
let candidateLocations: { pluginDir: string, pluginName: string }[] = []
for (let pluginDir of paths) {
pluginDir = normalizePath(pluginDir)
@@ -63,32 +89,44 @@ export async function findPlugins (): Promise<IPluginInfo[]> {
continue
}
let pluginNames = await fs.readdir(pluginDir)
for (let pluginName of pluginNames.filter(x => /^terminus-/.exec(x))) {
let pluginPath = path.join(pluginDir, pluginName)
let infoPath = path.join(pluginPath, 'package.json')
if (!await fs.exists(infoPath)) {
if (await fs.exists(path.join(pluginDir, 'package.json'))) {
candidateLocations.push({
pluginDir: path.dirname(pluginDir),
pluginName: path.basename(pluginDir)
})
}
for (let pluginName of pluginNames) {
candidateLocations.push({ pluginDir, pluginName })
}
}
for (let { pluginDir, pluginName } of candidateLocations) {
let pluginPath = path.join(pluginDir, pluginName)
let infoPath = path.join(pluginPath, 'package.json')
if (!await fs.exists(infoPath)) {
continue
}
if (foundPlugins.some(x => x.name === pluginName)) {
console.info(`Plugin ${pluginName} already exists`)
}
try {
let info = JSON.parse(await fs.readFile(infoPath, {encoding: 'utf-8'}))
if (!info.keywords || info.keywords.indexOf('terminus-plugin') === -1) {
continue
}
if (foundPlugins.some(x => x.name === pluginName)) {
console.info(`Plugin ${pluginName} already exists`)
}
try {
let info = JSON.parse(await fs.readFile(infoPath, {encoding: 'utf-8'}))
console.log(pluginDir, builtinPluginsPath)
foundPlugins.push({
name: pluginName.substring('terminus-'.length),
packageName: pluginName,
isBuiltin: pluginDir === builtinPluginsPath,
version: info.version,
description: info.description,
path: pluginPath,
info,
})
} catch (error) {
console.error('Cannot load package info for', pluginName)
}
foundPlugins.push({
name: pluginName.substring('terminus-'.length),
packageName: pluginName,
isBuiltin: pluginDir === builtinPluginsPath,
version: info.version,
description: info.description,
path: pluginPath,
info,
})
} catch (error) {
console.error('Cannot load package info for', pluginName)
}
}

View File

@@ -61,7 +61,7 @@ module.exports = {
'mz': 'commonjs mz',
'path': 'commonjs path',
'rxjs': 'commonjs rxjs',
'zone.js': 'commonjs zone.js',
'zone.js': 'commonjs zone.js/dist/zone.js',
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),

View File

@@ -80,5 +80,5 @@
"lint": "tslint -c tslint.json -t stylish terminus-*/src/**/*.ts terminus-*/src/*.ts app/src/*.ts",
"postinstall": "install-app-deps"
},
"false": {}
"repository": "eugeny/terminus"
}

View File

@@ -22,3 +22,4 @@ vars.builtinPlugins.forEach(plugin => {
}
sh.cd('..')
})
fs.unlinkSync(path.join(target, 'package.json'), '{}')

11
scripts/set-plugin-versions.js Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env node
const sh = require('shelljs')
const vars = require('./vars')
const log = require('npmlog')
vars.builtinPlugins.forEach(plugin => {
log.info('bump', plugin)
sh.cd(plugin)
sh.exec('npm --no-git-tag-version version ' + vars.version)
sh.cd('..')
})

View File

@@ -16,5 +16,4 @@ exports.builtinPlugins = [
'terminus-plugin-manager',
]
exports.nativeModules = ['node-pty', 'font-manager']
exports.version = appInfo.version
exports.electronVersion = pkgInfo.devDependencies.electron

View File

@@ -1,7 +1,8 @@
{
"name": "terminus-community-color-schemes",
"version": "0.0.1",
"version": "1.0.0-alpha.14",
"description": "Community color schemes for Terminus",
"keywords": ["terminus-plugin"],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {

View File

@@ -1,7 +1,8 @@
{
"name": "terminus-core",
"version": "0.0.1",
"version": "1.0.0-alpha.14",
"description": "Terminus core",
"keywords": ["terminus-plugin"],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {

View File

@@ -40,12 +40,12 @@ export class DockingService {
newBounds.height = Math.round(fill * display.bounds.height)
}
if (dockSide === 'right') {
newBounds.x = display.bounds.x + display.bounds.width * (1.0 - fill)
newBounds.x = display.bounds.x + Math.round(display.bounds.width * (1.0 - fill))
} else {
newBounds.x = display.bounds.x
}
if (dockSide === 'bottom') {
newBounds.y = display.bounds.y + display.bounds.height * (1.0 - fill)
newBounds.y = display.bounds.y + Math.round(display.bounds.height * (1.0 - fill))
} else {
newBounds.y = display.bounds.y
}

View File

@@ -1,7 +1,8 @@
{
"name": "terminus-plugin-manager",
"version": "0.0.1",
"version": "1.0.0-alpha.14",
"description": "Terminus' plugin manager",
"keywords": ["terminus-plugin"],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {

View File

@@ -1,7 +1,8 @@
{
"name": "terminus-settings",
"version": "0.0.1",
"version": "1.0.0-alpha.14",
"description": "Terminus terminal settings page",
"keywords": ["terminus-plugin"],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {

View File

@@ -109,17 +109,17 @@ ngb-tabset.vertical(type='tabs')
label Display on
br
div(
'[(ngModel)]'='config.store.appearance.dockScreen'
'(ngModelChange)'='config.save(); docking.dock()'
[(ngModel)]='config.store.appearance.dockScreen',
(ngModelChange)='config.save(); docking.dock()',
ngbRadioGroup
)
label.btn.btn-secondary
input(
type='radio',
[value]='"current"'
value='current'
)
| Current
label.btn.btn-secondary(*ngFor='let screen of docking.getScreens()')
label.btn.btn-secondary(*ngFor='let screen of screens')
input(
type='radio',
[value]='screen.id'

View File

@@ -14,6 +14,7 @@ import { SettingsTabProvider } from '../api'
export class SettingsTabComponent extends BaseTabComponent {
hotkeyFilter = ''
private hotkeyDescriptions: IHotkeyDescription[]
private screens
constructor (
public config: ConfigService,
@@ -28,6 +29,7 @@ export class SettingsTabComponent extends BaseTabComponent {
this.hotkeyDescriptions = hotkeyProviders.map(x => x.hotkeys).reduce((a, b) => a.concat(b))
this.title$.next('Settings')
this.scrollable = true
this.screens = this.docking.getScreens()
}
getRecoveryToken (): any {

View File

@@ -1,7 +1,8 @@
{
"name": "terminus-terminal",
"version": "0.0.1",
"version": "1.0.0-alpha.14",
"description": "Terminus' terminal emulation core",
"keywords": ["terminus-plugin"],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {

View File

@@ -1,6 +1,8 @@
import * as path from 'path'
import { exec } from 'mz/child_process'
import * as fs from 'mz/fs'
import { Injectable } from '@angular/core'
import { HotkeysService, ToolbarButtonProvider, IToolbarButton, AppService, ConfigService, ElectronService } from 'terminus-core'
import { HotkeysService, ToolbarButtonProvider, IToolbarButton, AppService, ConfigService, ElectronService, HostAppService, Platform } from 'terminus-core'
import { SessionsService } from './services/sessions.service'
import { TerminalTabComponent } from './components/terminalTab.component'
@@ -12,6 +14,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
private sessions: SessionsService,
private config: ConfigService,
private electron: ElectronService,
private hostApp: HostAppService,
hotkeys: HotkeysService,
) {
super()
@@ -43,6 +46,22 @@ export class ButtonProvider extends ToolbarButtonProvider {
'inject',
]
}
if (command === '~default-shell~') {
if (this.hostApp.platform === Platform.Linux) {
let line = (await fs.readFile('/etc/passwd', { encoding: 'utf-8' }))
.split('\n').find(x => x.startsWith(process.env.LOGNAME + ':'))
if (!line) {
console.warn('Could not detect user shell')
command = '/bin/sh'
} else {
command = line.split(':')[6]
}
}
if (this.hostApp.platform === Platform.macOS) {
let shellEntry = (await exec(`dscl . -read /Users/${process.env.LOGNAME} UserShell`))[0].toString()
command = shellEntry.split(':')[1].trim()
}
}
let sessionOptions = await this.sessions.prepareNewSession({ command, args, cwd })
this.app.openNewTab(
TerminalTabComponent,

View File

@@ -1,5 +1,5 @@
import { Observable } from 'rxjs'
import * as fs from 'fs-promise'
import * as fs from 'mz/fs'
import * as path from 'path'
import { exec } from 'mz/child_process'
const equal = require('deep-equal')
@@ -59,16 +59,20 @@ export class TerminalSettingsTabComponent {
{ name: 'CMD (stock)', command: 'cmd.exe' },
{ name: 'PowerShell', command: 'powershell.exe' },
]
// Detect whether BoW is installed
const wslPath = `${process.env.windir}\\system32\\bash.exe`
if (await fs.exists(wslPath)) {
this.shells.push({ name: 'Bash on Windows', command: wslPath })
}
// Detect Cygwin
let cygwinPath = await new Promise<string>(resolve => {
let reg = new Registry({ hive: Registry.HKLM, key: '\\Software\\Cygwin\\setup' })
reg.get('rootdir', (err, item) => {
if (err) {
resolve(null)
return
}
resolve(item.value)
})
@@ -76,13 +80,29 @@ export class TerminalSettingsTabComponent {
if (cygwinPath) {
this.shells.push({ name: 'Cygwin', command: path.join(cygwinPath, 'bin', 'bash.exe') })
}
// Detect Git-Bash
let gitBashPath = await new Promise<string>(resolve => {
let reg = new Registry({ hive: Registry.HKLM, key: '\\Software\\GitForWindows' })
reg.get('InstallPath', (err, item) => {
if (err) {
resolve(null)
return
}
resolve(item.value)
})
})
if (gitBashPath) {
this.shells.push({ name: 'Git-Bash', command: path.join(gitBashPath, 'bin', 'bash.exe') })
}
}
if (this.hostApp.platform === Platform.Linux || this.hostApp.platform === Platform.macOS) {
this.shells = (await fs.readFile('/etc/shells', 'utf-8'))
this.shells = [{ name: 'Default shell', command: '~default-shell~' }]
this.shells = this.shells.concat((await fs.readFile('/etc/shells', { encoding: 'utf-8' }))
.split('\n')
.map(x => x.trim())
.filter(x => x && !x.startsWith('#'))
.map(x => ({ name: x, command: x }))
.map(x => ({ name: x, command: x })))
}
this.colorSchemes = (await Promise.all(this.colorSchemeProviders.map(x => x.getSchemes()))).reduce((a, b) => a.concat(b))
}

View File

@@ -40,7 +40,7 @@ export class TerminalConfigProvider extends ConfigProvider {
[Platform.macOS]: {
terminal: {
font: 'Menlo',
shell: '/bin/zsh',
shell: '~default-shell~',
},
hotkeys: {
'new-tab': [
@@ -67,7 +67,7 @@ export class TerminalConfigProvider extends ConfigProvider {
[Platform.Linux]: {
terminal: {
font: 'Liberation Mono',
shell: '/bin/bash',
shell: '~default-shell~',
},
hotkeys: {
'new-tab': [

View File

@@ -100,7 +100,7 @@ export class ScreenPersistenceProvider extends SessionPersistenceProvider {
altscreen on
`, 'utf-8')
let recoveryId = `term-tab-${Date.now()}`
let args = ['-d', '-m', '-c', configPath, '-U', '-S', recoveryId, '-T', 'xterm-256color', '--', options.command].concat(options.args || [])
let args = ['-d', '-m', '-c', configPath, '-U', '-S', recoveryId, '-T', 'xterm-256color', '--', '-' + options.command].concat(options.args || [])
this.logger.debug('Spawning screen with', args.join(' '))
await spawn('screen', args, {
cwd: options.cwd,

View File

@@ -28,10 +28,6 @@ export class Session {
...options.env,
TERM: 'xterm-256color',
}
if (options.command.includes(' ')) {
options.args = ['-c', options.command]
options.command = 'sh'
}
this.pty = nodePTY.spawn(options.command, options.args || [], {
name: 'xterm-256color',
cols: options.width || 80,