From ae33338f2229cce3f68ca2321eaa6e34208d773b Mon Sep 17 00:00:00 2001 From: Chapman Pendery <35637443+cpendery@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:18:19 -0800 Subject: [PATCH] fix: only show 'powershell' binding on windows (#22) Signed-off-by: Chapman Pendery --- src/utils/bindings.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/utils/bindings.ts b/src/utils/bindings.ts index 674c877..91ffec9 100644 --- a/src/utils/bindings.ts +++ b/src/utils/bindings.ts @@ -20,7 +20,9 @@ export enum Shell { Fish = "fish", } -export const supportedShells = [Shell.Bash, Shell.Powershell, Shell.Pwsh, Shell.Zsh, Shell.Fish]; +export const supportedShells = [Shell.Bash, process.platform == "win32" ? Shell.Powershell : null, Shell.Pwsh, Shell.Zsh, Shell.Fish].filter( + (shell) => shell != null, +) as Shell[]; const bashScriptCommand = (): string => { return `[ -f ~/${cacheFolder}/key-bindings.bash ] && source ~/${cacheFolder}/key-bindings.bash`; @@ -93,13 +95,15 @@ export const availableBindings = async (): Promise => { } } - const powershellConfigPath = path.join(os.homedir(), "Documents", "WindowsPowershell", "Microsoft.PowerShell_profile.ps1"); - if (!fs.existsSync(powershellConfigPath)) { - bindings.push(Shell.Powershell); - } else { - const powershellConfigContent = fsAsync.readFile(powershellConfigPath, { encoding: "utf-8" }); - if (!(await powershellConfigContent).includes(powershellScriptCommand())) { + if (process.platform == "win32") { + const powershellConfigPath = path.join(os.homedir(), "Documents", "WindowsPowershell", "Microsoft.PowerShell_profile.ps1"); + if (!fs.existsSync(powershellConfigPath)) { bindings.push(Shell.Powershell); + } else { + const powershellConfigContent = fsAsync.readFile(powershellConfigPath, { encoding: "utf-8" }); + if (!(await powershellConfigContent).includes(powershellScriptCommand())) { + bindings.push(Shell.Powershell); + } } }