mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Allow to define the path of the shell in app preferences (#2194)
Co-authored-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
713ec8c69d
commit
5c6a6e14f5
@ -20,6 +20,7 @@ export interface UserStoreModel {
|
|||||||
|
|
||||||
export interface UserPreferences {
|
export interface UserPreferences {
|
||||||
httpsProxy?: string;
|
httpsProxy?: string;
|
||||||
|
shell?: string;
|
||||||
colorTheme?: string;
|
colorTheme?: string;
|
||||||
allowUntrustedCAs?: boolean;
|
allowUntrustedCAs?: boolean;
|
||||||
allowTelemetry?: boolean;
|
allowTelemetry?: boolean;
|
||||||
|
|||||||
@ -105,10 +105,11 @@ export class ShellSession extends EventEmitter {
|
|||||||
protected async getShellEnv() {
|
protected async getShellEnv() {
|
||||||
const env = JSON.parse(JSON.stringify(await shellEnv()));
|
const env = JSON.parse(JSON.stringify(await shellEnv()));
|
||||||
const pathStr = [this.kubectlBinDir, this.helmBinDir, process.env.PATH].join(path.delimiter);
|
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) {
|
if(isWindows) {
|
||||||
env["SystemRoot"] = process.env.SystemRoot;
|
env["SystemRoot"] = process.env.SystemRoot;
|
||||||
env["PTYSHELL"] = process.env.SHELL || "powershell.exe";
|
env["PTYSHELL"] = shell || "powershell.exe";
|
||||||
env["PATH"] = pathStr;
|
env["PATH"] = pathStr;
|
||||||
env["LENS_SESSION"] = "true";
|
env["LENS_SESSION"] = "true";
|
||||||
const lensWslEnv = "KUBECONFIG/up:LENS_SESSION/u";
|
const lensWslEnv = "KUBECONFIG/up:LENS_SESSION/u";
|
||||||
@ -118,8 +119,8 @@ export class ShellSession extends EventEmitter {
|
|||||||
} else {
|
} else {
|
||||||
env["WSLENV"] = lensWslEnv;
|
env["WSLENV"] = lensWslEnv;
|
||||||
}
|
}
|
||||||
} else if(typeof(process.env.SHELL) != "undefined") {
|
} else if(shell !== undefined) {
|
||||||
env["PTYSHELL"] = process.env.SHELL;
|
env["PTYSHELL"] = shell;
|
||||||
env["PATH"] = pathStr;
|
env["PATH"] = pathStr;
|
||||||
} else {
|
} else {
|
||||||
env["PTYSHELL"] = ""; // blank runs the system default shell
|
env["PTYSHELL"] = ""; // blank runs the system default shell
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { action, computed, observable } from "mobx";
|
|||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { Select, SelectOption } from "../select";
|
import { Select, SelectOption } from "../select";
|
||||||
import { userStore } from "../../../common/user-store";
|
import { userStore } from "../../../common/user-store";
|
||||||
|
import { isWindows } from "../../../common/vars";
|
||||||
import { HelmRepo, repoManager } from "../../../main/helm/helm-repo-manager";
|
import { HelmRepo, repoManager } from "../../../main/helm/helm-repo-manager";
|
||||||
import { Input } from "../input";
|
import { Input } from "../input";
|
||||||
import { Checkbox } from "../checkbox";
|
import { Checkbox } from "../checkbox";
|
||||||
@ -25,6 +26,7 @@ export class Preferences extends React.Component {
|
|||||||
@observable helmRepos: HelmRepo[] = [];
|
@observable helmRepos: HelmRepo[] = [];
|
||||||
@observable helmAddedRepos = observable.map<string, HelmRepo>();
|
@observable helmAddedRepos = observable.map<string, HelmRepo>();
|
||||||
@observable httpProxy = userStore.preferences.httpsProxy || "";
|
@observable httpProxy = userStore.preferences.httpsProxy || "";
|
||||||
|
@observable shell = userStore.preferences.shell || "";
|
||||||
|
|
||||||
@computed get themeOptions(): SelectOption<string>[] {
|
@computed get themeOptions(): SelectOption<string>[] {
|
||||||
return themeStore.themes.map(theme => ({
|
return themeStore.themes.map(theme => ({
|
||||||
@ -109,6 +111,15 @@ export class Preferences extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const { preferences } = userStore;
|
const { preferences } = userStore;
|
||||||
const header = <h2>Preferences</h2>;
|
const header = <h2>Preferences</h2>;
|
||||||
|
let defaultShell = process.env.SHELL || process.env.PTYSHELL;
|
||||||
|
|
||||||
|
if (!defaultShell) {
|
||||||
|
if (isWindows) {
|
||||||
|
defaultShell = "powershell.exe";
|
||||||
|
} else {
|
||||||
|
defaultShell = "System default shell";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout showOnTop className="Preferences" header={header}>
|
<PageLayout showOnTop className="Preferences" header={header}>
|
||||||
@ -130,7 +141,17 @@ export class Preferences extends React.Component {
|
|||||||
<small className="hint">
|
<small className="hint">
|
||||||
Proxy is used only for non-cluster communication.
|
Proxy is used only for non-cluster communication.
|
||||||
</small>
|
</small>
|
||||||
|
<h2>Terminal Shell</h2>
|
||||||
|
<Input
|
||||||
|
theme="round-black"
|
||||||
|
placeholder={defaultShell}
|
||||||
|
value={this.shell}
|
||||||
|
onChange={v => this.shell = v}
|
||||||
|
onBlur={() => preferences.shell = this.shell}
|
||||||
|
/>
|
||||||
|
<small className="hint">
|
||||||
|
The path of the shell that the terminal uses.
|
||||||
|
</small>
|
||||||
<KubectlBinaries preferences={preferences}/>
|
<KubectlBinaries preferences={preferences}/>
|
||||||
|
|
||||||
<h2>Helm</h2>
|
<h2>Helm</h2>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user