Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: trailing whitespace after shell plugin causes extra doctor warnings #323

Merged
merged 1 commit into from
Jan 6, 2025
Merged
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
11 changes: 6 additions & 5 deletions src/utils/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ export const checkShellConfigPlugin = async () => {
if (profilePath != null && fs.existsSync(profilePath)) {
const profile = await fsAsync.readFile(profilePath, "utf8");

const profileContainsSource = profile.includes(getShellSourceCommand(shell));
const profileEndsWithSource = profile.trimEnd().endsWith(getShellSourceCommand(shell));
const shellSourceCommand = getShellSourceCommand(shell).trim();
const profileContainsSource = profile.includes(shellSourceCommand);
const profileEndsWithSource = profile.trimEnd().endsWith(shellSourceCommand);

if (!profileContainsSource) {
shellsWithoutPlugin.push(shell);
Expand Down Expand Up @@ -278,17 +279,17 @@ export const getShellSourceCommand = (shell: Shell): string => {
case Shell.Bash:
return `[ -f ~/.inshellisense/bash/init.sh ] && source ~/.inshellisense/bash/init.sh`;
case Shell.Powershell:
return `if ( Test-Path '~/.inshellisense/powershell/init.ps1' -PathType Leaf ) { . ~/.inshellisense/powershell/init.ps1 } `;
return `if ( Test-Path '~/.inshellisense/powershell/init.ps1' -PathType Leaf ) { . ~/.inshellisense/powershell/init.ps1 }`;
case Shell.Pwsh:
return `if ( Test-Path '~/.inshellisense/pwsh/init.ps1' -PathType Leaf ) { . ~/.inshellisense/pwsh/init.ps1 } `;
return `if ( Test-Path '~/.inshellisense/pwsh/init.ps1' -PathType Leaf ) { . ~/.inshellisense/pwsh/init.ps1 }`;
case Shell.Zsh:
return `[[ -f ~/.inshellisense/zsh/init.zsh ]] && source ~/.inshellisense/zsh/init.zsh`;
case Shell.Fish:
return `test -f ~/.inshellisense/fish/init.fish && source ~/.inshellisense/fish/init.fish`;
case Shell.Xonsh:
return `p"~/.inshellisense/xonsh/init.xsh".exists() && source "~/.inshellisense/xonsh/init.xsh"`;
case Shell.Nushell:
return `if ( '~/.inshellisense/nu/init.nu' | path exists ) { source ~/.inshellisense/nu/init.nu } `;
return `if ( '~/.inshellisense/nu/init.nu' | path exists ) { source ~/.inshellisense/nu/init.nu }`;
}
return "";
};
Expand Down
Loading