mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-19 02:49:56 +00:00
35 lines
945 B
TypeScript
35 lines
945 B
TypeScript
import * as fs from 'mz/fs'
|
|
import slugify from 'slugify'
|
|
import { Injectable } from '@angular/core'
|
|
import { HostAppService, Platform } from 'terminus-core'
|
|
|
|
import { ShellProvider } from '../api/shellProvider'
|
|
import { Shell } from '../api/interfaces'
|
|
|
|
/** @hidden */
|
|
@Injectable()
|
|
export class POSIXShellsProvider extends ShellProvider {
|
|
constructor (
|
|
private hostApp: HostAppService,
|
|
) {
|
|
super()
|
|
}
|
|
|
|
async provide (): Promise<Shell[]> {
|
|
if (this.hostApp.platform === Platform.Windows) {
|
|
return []
|
|
}
|
|
return (await fs.readFile('/etc/shells', { encoding: 'utf-8' }))
|
|
.split('\n')
|
|
.map(x => x.trim())
|
|
.filter(x => x && !x.startsWith('#'))
|
|
.map(x => ({
|
|
id: slugify(x),
|
|
name: x.split('/')[2],
|
|
command: x,
|
|
args: ['-l'],
|
|
env: {},
|
|
}))
|
|
}
|
|
}
|