From 5c6a6e14f59c0ff9a750c41fa699a8be521d1a37 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Thu, 11 Mar 2021 18:25:06 +0200 Subject: [PATCH] Allow to define the path of the shell in app preferences (#2194) Co-authored-by: Sebastian Malton --- src/common/user-store.ts | 1 + src/main/shell-session.ts | 7 +++--- .../components/+preferences/preferences.tsx | 23 ++++++++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/common/user-store.ts b/src/common/user-store.ts index b0294d9e5a..3df9125224 100644 --- a/src/common/user-store.ts +++ b/src/common/user-store.ts @@ -20,6 +20,7 @@ export interface UserStoreModel { export interface UserPreferences { httpsProxy?: string; + shell?: string; colorTheme?: string; allowUntrustedCAs?: boolean; allowTelemetry?: boolean; diff --git a/src/main/shell-session.ts b/src/main/shell-session.ts index 10a2f9ed47..a8c6a36e72 100644 --- a/src/main/shell-session.ts +++ b/src/main/shell-session.ts @@ -105,10 +105,11 @@ export class ShellSession extends EventEmitter { protected async getShellEnv() { const env = JSON.parse(JSON.stringify(await shellEnv())); const pathStr = [this.kubectlBinDir, this.helmBinDir, process.env.PATH].join(path.delimiter); + const shell = userStore.preferences.shell || process.env.SHELL || process.env.PTYSHELL; if(isWindows) { env["SystemRoot"] = process.env.SystemRoot; - env["PTYSHELL"] = process.env.SHELL || "powershell.exe"; + env["PTYSHELL"] = shell || "powershell.exe"; env["PATH"] = pathStr; env["LENS_SESSION"] = "true"; const lensWslEnv = "KUBECONFIG/up:LENS_SESSION/u"; @@ -118,8 +119,8 @@ export class ShellSession extends EventEmitter { } else { env["WSLENV"] = lensWslEnv; } - } else if(typeof(process.env.SHELL) != "undefined") { - env["PTYSHELL"] = process.env.SHELL; + } else if(shell !== undefined) { + env["PTYSHELL"] = shell; env["PATH"] = pathStr; } else { env["PTYSHELL"] = ""; // blank runs the system default shell diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index b0442f45b6..2493599b2a 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -6,6 +6,7 @@ import { action, computed, observable } from "mobx"; import { Icon } from "../icon"; import { Select, SelectOption } from "../select"; import { userStore } from "../../../common/user-store"; +import { isWindows } from "../../../common/vars"; import { HelmRepo, repoManager } from "../../../main/helm/helm-repo-manager"; import { Input } from "../input"; import { Checkbox } from "../checkbox"; @@ -25,6 +26,7 @@ export class Preferences extends React.Component { @observable helmRepos: HelmRepo[] = []; @observable helmAddedRepos = observable.map(); @observable httpProxy = userStore.preferences.httpsProxy || ""; + @observable shell = userStore.preferences.shell || ""; @computed get themeOptions(): SelectOption[] { return themeStore.themes.map(theme => ({ @@ -109,6 +111,15 @@ export class Preferences extends React.Component { render() { const { preferences } = userStore; const header =

Preferences

; + let defaultShell = process.env.SHELL || process.env.PTYSHELL; + + if (!defaultShell) { + if (isWindows) { + defaultShell = "powershell.exe"; + } else { + defaultShell = "System default shell"; + } + } return ( @@ -130,7 +141,17 @@ export class Preferences extends React.Component { Proxy is used only for non-cluster communication. - +

Terminal Shell

+ this.shell = v} + onBlur={() => preferences.shell = this.shell} + /> + + The path of the shell that the terminal uses. +

Helm