Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/runtime/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const executeShellCommand = await buildExecuteShellCommand(5_000);

const loadBashAliases = async () => {
const shellTarget = platform == "win32" ? await gitBashPath() : Shell.Bash;
const { stdout, stderr, status } = await executeShellCommand({ command: shellTarget, args: ["-i", "-c", "alias"], cwd: process.cwd() });
const { stdout, stderr, status } = await executeShellCommand({ command: shellTarget, args: ["-i", "-c", "alias"], cwd: process.cwd(), env: { ISTERM: "1" } });
if (status !== 0) {
log.debug({ msg: "failed to load bash aliases", stderr, status });
return;
Expand All @@ -29,7 +29,7 @@ const loadBashAliases = async () => {
};

const loadZshAliases = async () => {
const { stdout, stderr, status } = await executeShellCommand({ command: Shell.Zsh, args: ["-i", "-c", "alias"], cwd: process.cwd() });
const { stdout, stderr, status } = await executeShellCommand({ command: Shell.Zsh, args: ["-i", "-c", "alias"], cwd: process.cwd(), env: { ISTERM: "1" } });
if (status !== 0) {
log.debug({ msg: "failed to load zsh aliases", stderr, status });
return;
Expand Down
12 changes: 5 additions & 7 deletions src/utils/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ import log from "./log.js";

const exec = util.promisify(childProcess.exec);
const safeExec = async (command: string, options?: childProcess.ExecOptions) => {
const defaultOptions: childProcess.ExecOptions = { timeout: 500, env: { ISTERM: "1" } };
try {
const { stdout, stderr } = await exec(command, options);
return {
stdout: typeof stdout === "string" ? stdout : stdout.toString(),
stderr: typeof stderr === "string" ? stderr : stderr.toString(),
};
const { stdout, stderr } = await exec(command, { ...defaultOptions, ...options });
return { stdout, stderr };
} catch (e) {
log.debug({ msg: `error executing exec command: ${e}` });
return { stdout: undefined, stderr: undefined };
Expand Down Expand Up @@ -112,15 +110,15 @@ const getProfilePath = async (shell: Shell): Promise<string | undefined> => {
case Shell.Powershell:
return (await safeExec(`echo $profile`, { shell })).stdout?.trim();
case Shell.Pwsh:
return (await safeExec(`echo $profile`, { shell })).stdout?.trim();
return (await safeExec(`echo $profile`, { shell, timeout: 500, env: { ISTERM: "1" } })).stdout?.trim();
case Shell.Zsh:
return path.join(os.homedir(), ".zshrc");
case Shell.Fish:
return path.join(os.homedir(), ".config", "fish", "config.fish");
case Shell.Xonsh:
return path.join(os.homedir(), ".xonshrc");
case Shell.Nushell:
return (await safeExec(`echo $nu.env-path`, { shell })).stdout?.trim();
return (await safeExec(`echo $nu.env-path`, { shell, timeout: 500, env: { ISTERM: "1" } })).stdout?.trim();
}
};

Expand Down
Loading