mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 13:48:41 -09:00
Add support for environment variables in config (#534)
* Allow env to be specified in config (#424) This is referencing #424. User specified environment variables in the `.hyperterm.js` file are expected under a field named `env`. An example config: ``` module.exports = { config: { ... // Environment variables env: { WHAT_UP: 'heyo', } ... }, plugins: [], localPlugins: [] }; ``` * Add env field to default config
This commit is contained in:
parent
20e8d5e169
commit
011ae3fd52
2 changed files with 8 additions and 2 deletions
|
|
@ -54,7 +54,10 @@ module.exports = {
|
||||||
|
|
||||||
// the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
|
// the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
|
||||||
// if left empty, your system's login shell will be used by default
|
// if left empty, your system's login shell will be used by default
|
||||||
shell: ''
|
shell: '',
|
||||||
|
|
||||||
|
// for environment variables
|
||||||
|
env: {}
|
||||||
|
|
||||||
// for advanced config flags please refer to https://hyperterm.org/#cfg
|
// for advanced config flags please refer to https://hyperterm.org/#cfg
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ const { exec } = require('child_process');
|
||||||
const defaultShell = require('default-shell');
|
const defaultShell = require('default-shell');
|
||||||
const { getDecoratedEnv } = require('./plugins');
|
const { getDecoratedEnv } = require('./plugins');
|
||||||
const { productName, version } = require('./package');
|
const { productName, version } = require('./package');
|
||||||
|
const config = require('./config');
|
||||||
|
|
||||||
let spawn;
|
let spawn;
|
||||||
try {
|
try {
|
||||||
|
|
@ -19,6 +20,8 @@ try {
|
||||||
|
|
||||||
const TITLE_POLL_INTERVAL = 500;
|
const TITLE_POLL_INTERVAL = 500;
|
||||||
|
|
||||||
|
const envFromConfig = config.getConfig().env || {};
|
||||||
|
|
||||||
module.exports = class Session extends EventEmitter {
|
module.exports = class Session extends EventEmitter {
|
||||||
|
|
||||||
constructor ({ rows, cols: columns, cwd, shell }) {
|
constructor ({ rows, cols: columns, cwd, shell }) {
|
||||||
|
|
@ -28,7 +31,7 @@ module.exports = class Session extends EventEmitter {
|
||||||
TERM: 'xterm-256color',
|
TERM: 'xterm-256color',
|
||||||
TERM_PROGRAM: productName,
|
TERM_PROGRAM: productName,
|
||||||
TERM_PROGRAM_VERSION: version
|
TERM_PROGRAM_VERSION: version
|
||||||
});
|
}, envFromConfig);
|
||||||
|
|
||||||
this.pty = spawn(shell || defaultShell, ['--login'], {
|
this.pty = spawn(shell || defaultShell, ['--login'], {
|
||||||
columns,
|
columns,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue