Git-bash support (fixes #12)

This commit is contained in:
Eugene Pankov
2017-06-30 19:54:17 +02:00
parent 165ab1cfbf
commit 77b55a003c
3 changed files with 20 additions and 5 deletions

View File

@@ -16,7 +16,7 @@ export interface ResizeEvent {
export interface SessionOptions { export interface SessionOptions {
name?: string name?: string
command?: string command?: string|string[]
args?: string[] args?: string[]
cwd?: string cwd?: string
env?: any env?: any

View File

@@ -59,16 +59,20 @@ export class TerminalSettingsTabComponent {
{ name: 'CMD (stock)', command: 'cmd.exe' }, { name: 'CMD (stock)', command: 'cmd.exe' },
{ name: 'PowerShell', command: 'powershell.exe' }, { name: 'PowerShell', command: 'powershell.exe' },
] ]
// Detect whether BoW is installed
const wslPath = `${process.env.windir}\\system32\\bash.exe` const wslPath = `${process.env.windir}\\system32\\bash.exe`
if (await fs.exists(wslPath)) { if (await fs.exists(wslPath)) {
this.shells.push({ name: 'Bash on Windows', command: wslPath }) this.shells.push({ name: 'Bash on Windows', command: wslPath })
} }
// Detect Cygwin
let cygwinPath = await new Promise<string>(resolve => { let cygwinPath = await new Promise<string>(resolve => {
let reg = new Registry({ hive: Registry.HKLM, key: '\\Software\\Cygwin\\setup' }) let reg = new Registry({ hive: Registry.HKLM, key: '\\Software\\Cygwin\\setup' })
reg.get('rootdir', (err, item) => { reg.get('rootdir', (err, item) => {
if (err) { if (err) {
resolve(null) resolve(null)
return
} }
resolve(item.value) resolve(item.value)
}) })
@@ -76,6 +80,21 @@ export class TerminalSettingsTabComponent {
if (cygwinPath) { if (cygwinPath) {
this.shells.push({ name: 'Cygwin', command: path.join(cygwinPath, 'bin', 'bash.exe') }) 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) { if (this.hostApp.platform === Platform.Linux || this.hostApp.platform === Platform.macOS) {
this.shells = (await fs.readFile('/etc/shells', 'utf-8')) this.shells = (await fs.readFile('/etc/shells', 'utf-8'))

View File

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