Skip to content

Instantly share code, notes, and snippets.

@Kambaa
Last active February 20, 2024 06:20
Show Gist options
  • Save Kambaa/e4fe9765896fd4c101e97c72ad76d385 to your computer and use it in GitHub Desktop.
Save Kambaa/e4fe9765896fd4c101e97c72ad76d385 to your computer and use it in GitHub Desktop.
powershell quit alias & git autocomplete

Powershell goodies:

Powershell (newer or older) add a profile file (like linux's .bash_profile)

  • open powershell(or pwsh) as administrator
  • check if file exists with this command:Test-Path $profile or try to directly open it with this one: notepad $PROFILE
  • if error occurs run this command to add one New-Item -ItemType File -Path $profile -Force
  • open the profile file:notepad $PROFILE

Define an alias q as quit:

  • open powershell(or pwsh) as admin and the profile file: notepad $PROFILE
  • add this to the bottom:
function QuitReplacement{
Invoke-command -ScriptBlock {exit}
}

New-Alias -Name q -Value QuitReplacement

Git autocomplete:

  • Open powershell(or pwsh) as administrator and install posh-git: Install-Module posh-git -Scope CurrentUser
  • open the profile file:notepad $PROFILE and add this for it to work every session: Import-Module posh-git

SetEecution Error Problem Fix:

  • If you have any errors about exceution policies, allow them like this Run this: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment