microsoft / inshellisense

IDE style command line auto complete
MIT License
8.24k stars 181 forks source link

Powershell: Can't get the correct profile path #18

Closed Gaojianli closed 8 months ago

Gaojianli commented 8 months ago

Describe the bug Try to run inshellisense bind in powershell on macOS and got following error:

$ inshellisense bind
Select your desired shell for keybinding creation
  bash
  zsh
  fish
> powershell
  pwsh
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: ENOENT: no such file or directory, open '/Users/username/Documents/WindowsPowershell/Microsoft.PowerShell_profile.ps1'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/username/Documents/WindowsPowershell/Microsoft.PowerShell_profile.ps1'
}

To Reproduce Steps to reproduce the behavior:

  1. Open powershell on macOS
  2. Run inshellisense bind

Expected behavior The correct profile path is ~/.config/powershell/Microsoft.PowerShell_profile.ps1

$ file $PROFILE                                                  
/Users/user/.config/powershell/Microsoft.PowerShell_profile.ps1: ASCII text

Environment

Additional context Add any other context about the problem here.

Gaojianli commented 8 months ago

After manually insert the key-bindings into the profile,:

if(Test-Path '/Users/username/.inshellisense/key-bindings-pwsh.ps1' -PathType Leaf){. /Users/username/.inshellisense/key-bindings-pwsh.ps1}

I got another error:

node:internal/modules/cjs/loader:1147
  throw err;
  ^

Error: Cannot find module '/Users/username/\AppData\Roaming\npm\node_modules\@microsoft\inshellisense\build\index.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

It seems that there are some hard-code paths for windows...

Delta456 commented 8 months ago

Powershell and pwsh are completely different. Powershell is Windows only and pwsh is cross-platform.