gerardog / gsudo

Sudo for Windows
https://gerardog.github.io/gsudo
MIT License
5.07k stars 136 forks source link

Issue: `gsudo !!` works in PowerShell but `sudo !!` doesn't #357

Closed MigProPlayer closed 1 month ago

MigProPlayer commented 1 month ago

Issue Description

After adding Import-Module 'gsudoModule' to my Powershell 7 profile, executing the last command with gusdo !! works. But trying to do the same thing but with the sudo alias (sudo !!) throws out an error about the module not being imported. The sudo alias works for everything else except doing sudo !!.

Steps to Reproduce

  1. Add Import-Module 'gsudoModule' to your powershell profile
  2. Reload your console
  3. Execute a command that needs admin
  4. Use sudo !! to rerun that command as admin
  5. See it error out

Screenshots

image

Context:

gerardog commented 1 month ago

Hi, The behaviour is intentional: to not mess with other sudo tools, if exists. The problem is the documentation is poor and needs to document this.

Please add this to your profile, after Import-Module gsudoModule:

And btw, since you have gsudoModule, instead of !!, you may want to write gsudo + space + tab key

> Do-Something
Insuficient Access
> gsudo [press tab key]  --> will autocomplete with:
> gsudo { Do-Something }

I think that one featyre is much better than !!

MigProPlayer commented 1 month ago

Oh, I didn't know it was an intended feature. Thank you for letting me know! I'll make sure to check the autocompletion later on.