feat: add cmd.exe support (#126)

* feat: add cmd.exe support

Signed-off-by: Chapman Pendery <cpendery@vt.edu>

* fix: add template to logging failure

Signed-off-by: Chapman Pendery <cpendery@vt.edu>

---------

Signed-off-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
Chapman Pendery
2023-12-14 15:44:21 -08:00
committed by GitHub
parent dded563f26
commit 6928eecb8f
3 changed files with 24 additions and 12 deletions
+1
View File
@@ -49,6 +49,7 @@ inshellisense supports the following shells:
- [fish](https://github.com/fish-shell/fish-shell)
- [pwsh](https://github.com/PowerShell/PowerShell)
- [powershell](https://learn.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-windows-powershell) (Windows Powershell)
- [cmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd) _(experimental)_
## Contributing
+15 -9
View File
@@ -2,6 +2,7 @@
// Licensed under the MIT License.
import fsAsync from "node:fs/promises";
import log from "../utils/log.js";
const filepathsTemplate = async (cwd: string): Promise<Fig.Suggestion[]> => {
const files = await fsAsync.readdir(cwd, { withFileTypes: true });
@@ -28,15 +29,20 @@ export const runTemplates = async (template: Fig.TemplateStrings[] | Fig.Templat
return (
await Promise.all(
templates.map(async (t) => {
switch (t) {
case "filepaths":
return await filepathsTemplate(cwd);
case "folders":
return await foldersTemplate(cwd);
case "history":
return historyTemplate();
case "help":
return helpTemplate();
try {
switch (t) {
case "filepaths":
return await filepathsTemplate(cwd);
case "folders":
return await foldersTemplate(cwd);
case "history":
return historyTemplate();
case "help":
return helpTemplate();
}
} catch (e) {
log.debug({ msg: "template failed", e, template: t, cwd });
return [];
}
}),
)
+8 -3
View File
@@ -19,9 +19,14 @@ export enum Shell {
Cmd = "cmd",
}
export const supportedShells = [Shell.Bash, process.platform == "win32" ? Shell.Powershell : null, Shell.Pwsh, Shell.Zsh, Shell.Fish].filter(
(shell) => shell != null,
) as Shell[];
export const supportedShells = [
Shell.Bash,
process.platform == "win32" ? Shell.Powershell : null,
Shell.Pwsh,
Shell.Zsh,
Shell.Fish,
process.platform == "win32" ? Shell.Cmd : null,
].filter((shell) => shell != null) as Shell[];
export const userZdotdir = process.env?.ZDOTDIR ?? os.homedir() ?? `~`;
export const zdotdir = path.join(os.tmpdir(), `is-zsh`);