Skip to content

Commit

Permalink
🐛 separate shell and shellArgs GitSquared#791
Browse files Browse the repository at this point in the history
  • Loading branch information
GitSquared authored and eugene2candy committed Apr 10, 2021
1 parent ff2e4f9 commit f77ab20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/_boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ try {
if (!fs.existsSync(settingsFile)) {
fs.writeFileSync(settingsFile, JSON.stringify({
shell: (process.platform === "win32") ? "powershell.exe" : "bash",
shellArgs: '',
cwd: electron.app.getPath("userData"),
keyboard: "en-US",
theme: "tron",
Expand Down Expand Up @@ -223,7 +224,7 @@ app.on('ready', async () => {
if (!require("fs").existsSync(settings.cwd)) throw new Error("Configured cwd path does not exist.");

// See #366
let cleanEnv = await require("shell-env")(settings.shell.split(" ")[0]).catch(e => { throw e; });
let cleanEnv = await require("shell-env")(settings.shell).catch(e => { throw e; });

Object.assign(cleanEnv, process.env, {
TERM: "xterm-256color",
Expand All @@ -235,8 +236,8 @@ app.on('ready', async () => {
signale.pending(`Creating new terminal process on port ${settings.port || '3000'}`);
tty = new Terminal({
role: "server",
shell: settings.shell.split(" ")[0],
params: settings.shell.split(" ").splice(1),
shell: settings.shell,
params: settings.shellArgs || '',
cwd: settings.cwd,
env: cleanEnv,
port: settings.port || 3000
Expand Down Expand Up @@ -290,8 +291,8 @@ app.on('ready', async () => {
signale.pending(`Creating new TTY process on port ${port}`);
let term = new Terminal({
role: "server",
shell: settings.shell.split(" ")[0],
params: settings.shell.split(" ").splice(1),
shell: settings.shell,
params: settings.shellArgs || '',
cwd: tty.tty._cwd || settings.cwd,
env: cleanEnv,
port: port
Expand Down
6 changes: 6 additions & 0 deletions src/_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ window.openSettings = async () => {
<td>The program to run as a terminal emulator</td>
<td><input type="text" id="settingsEditor-shell" value="${window.settings.shell}"></td>
</tr>
<tr>
<td>shellArgs</td>
<td>Arguments to pass to the shell</td>
<td><input type="text" id="settingsEditor-shellArgs" value="${window.settings.shellArgs || ''}"></td>
</tr>
<tr>
<td>cwd</td>
<td>Working Directory to start in</td>
Expand Down Expand Up @@ -816,6 +821,7 @@ window.writeFile = (path) => {
window.writeSettingsFile = () => {
window.settings = {
shell: document.getElementById("settingsEditor-shell").value,
shellArgs: document.getElementById("settingsEditor-shellArgs").value,
cwd: document.getElementById("settingsEditor-cwd").value,
env: document.getElementById("settingsEditor-env").value,
username: document.getElementById("settingsEditor-username").value,
Expand Down

0 comments on commit f77ab20

Please sign in to comment.