diff --git a/README.md b/README.md index adb52106..4b62e6c4 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/docs/docs/usage/powershell.md b/docs/docs/usage/powershell.md index a1692402..d0974bae 100644 --- a/docs/docs/usage/powershell.md +++ b/docs/docs/usage/powershell.md @@ -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 diff --git a/installgsudo.ps1 b/installgsudo.ps1 index 52331943..d050639d 100644 --- a/installgsudo.ps1 +++ b/installgsudo.ps1 @@ -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 diff --git a/src/gsudo/Commands/BangBangCommand.cs b/src/gsudo/Commands/BangBangCommand.cs index b638b7df..64be483a 100644 --- a/src/gsudo/Commands/BangBangCommand.cs +++ b/src/gsudo/Commands/BangBangCommand.cs @@ -16,8 +16,7 @@ public Task 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;