mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
fix: only show 'powershell' binding on windows (#22)
Signed-off-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
+11
-7
@@ -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<Shell[]> => {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user