gerardog/gsudo

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

MigProPlayer opened this issue · 2 comments

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:

  • Windows version: Win11 Pro 23H2 - English
  • gsudo version: 2.5.0
  • PowerShell version: 7.4.2

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:

  • Set-Alias sudo gsudo
    That will fix the issue.

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 !!

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.