Skip to content

Commit

Permalink
Updated docs to suggest Import-Module gsudoModule instead of the ab…
Browse files Browse the repository at this point in the history
…solute path.
  • Loading branch information
gerardog committed Jul 17, 2023
1 parent fc2345f commit 5dbf0b6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ Alternative syntaxes:

``` Powershell
# Add the following line to your $PROFILE
Import-Module "$env:ProgramFiles\gsudo\Current\gsudoModule.psd1"
Import-Module "gsudoModule"
# Or run:
Get-Command gsudoModule.psd1 | % { Write-Output "`nImport-Module `"$($_.Source)`"" | Add-Content $PROFILE }
Write-Output "`nImport-Module `"gsudoModule`"" | Add-Content $PROFILE
```

- If you haven't already customized your PowerShell prompt (for example by installing Oh-My-Posh), you can easily add a red `#` indicating that the current process is elevated:
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/usage/powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ gsudo -d dir C:\
Add the following line to your $PROFILE (replace with full path)

``` powershell
Import-Module 'C:\FullPathTo\gsudoModule.psd1'
Import-Module 'gsudoModule.psd1'
# Or let the following line do it for you run:
Get-Command gsudoModule.psd1 | % { Write-Output "`nImport-Module `"$($_.Source)`"" | Add-Content $PROFILE }
Write-Output "`nImport-Module `"gsudoModule`"" | Add-Content $PROFILE
```

:::tip
Expand Down
3 changes: 2 additions & 1 deletion installgsudo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ if ($process.ExitCode -ne 0)
}
else
{
New-Item -Type Directory ($PROFILE | Split-Path) -ErrorAction SilentlyContinue

Write-Output "gsudo installed succesfully!"
Write-Output "Please restart your consoles to use gsudo!`n"

"PowerShell users: To use enhanced gsudo and Invoke-Gsudo cmdlet, add the following line to your `$PROFILE"
" Import-Module 'gsudoModule'"
"Or run: "
" New-Item -Type Directory (`$PROFILE | Split-Path) -ErrorAction Ignore"
" Write-Output `"``nImport-Module 'gsudoModule'`" | Add-Content `$PROFILE"

Remove-Item $fileName
Expand Down
3 changes: 1 addition & 2 deletions src/gsudo/Commands/BangBangCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public Task<int> Execute()
{
if (ShellHelper.InvokingShell.In (Shell.PowerShell, Shell.PowerShellCore, Shell.PowerShellCore623BuggedGlobalInstall))
{
var module = Path.Combine(Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), "gsudoModule.psd1");
throw new ApplicationException($"To use `gsudo !!` from powershell, run or add the following line to your `$PROFILE:\n\n Import-Module '{ module }'");
throw new ApplicationException($"To use `gsudo !!` from PowerShell, run or add the following line to your PowerShell $PROFILE:\n\n Import-Module 'gsudoModule'");
}

var caller = Process.GetCurrentProcess().GetShellProcess().MainModule.ModuleName;
Expand Down

0 comments on commit 5dbf0b6

Please sign in to comment.