Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit 57f93d8

Browse files
committed
♻️ Better environment variables for child terms
1 parent 0d1d1c1 commit 57f93d8

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/_boot.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,28 +159,30 @@ function createWindow(settings) {
159159
signale.watch("Waiting for frontend connection...");
160160
}
161161

162-
app.on('ready', () => {
162+
app.on('ready', async () => {
163163
signale.pending(`Loading settings file...`);
164164
let settings = require(settingsFile);
165165
signale.success(`Settings loaded!`);
166166

167167
if (!require("fs").existsSync(settings.cwd)) throw new Error("Configured cwd path does not exist.");
168168

169-
let customEnv;
170-
171169
// See #366
172-
if (process.platform === "darwin") {
173-
const shellEnv = require("shell-env");
174-
customEnv = shellEnv.sync();
175-
}
170+
let cleanEnv = await require("shell-env")(settings.shell).catch(e => { throw e; });
171+
172+
Object.assign(cleanEnv, process.env, settings.env, {
173+
TERM: "xterm-256color",
174+
COLORTERM: "truecolor",
175+
TERM_PROGRAM: "eDEX-UI",
176+
TERM_PROGRAM_VERSION: app.getVersion()
177+
});
176178

177179
signale.pending(`Creating new terminal process on port ${settings.port || '3000'}`);
178180
tty = new Terminal({
179181
role: "server",
180182
shell: settings.shell.split(" ")[0],
181183
params: settings.shell.split(" ").splice(1),
182184
cwd: settings.cwd,
183-
env: customEnv || settings.env,
185+
env: cleanEnv,
184186
port: settings.port || 3000
185187
});
186188
signale.success(`Terminal back-end initialized!`);
@@ -235,7 +237,7 @@ app.on('ready', () => {
235237
shell: settings.shell.split(" ")[0],
236238
params: settings.shell.split(" ").splice(1),
237239
cwd: tty.tty._cwd || settings.cwd,
238-
env: customEnv || settings.env,
240+
env: cleanEnv,
239241
port: port
240242
});
241243
signale.success(`New terminal back-end initialized at ${port}`);

src/classes/terminal.class.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ class Terminal {
333333
}
334334
}, 1000);
335335

336-
this.tty = this.Pty.spawn(opts.shell || "bash", opts.params || [], {
337-
name: "xterm-color",
336+
this.tty = this.Pty.spawn(opts.shell || "bash", opts.params || ["--login"], {
337+
name: "xterm-256color",
338338
cols: 80,
339339
rows: 24,
340340
cwd: opts.cwd || process.env.PWD,

0 commit comments

Comments
 (0)