Last active
April 3, 2023 17:23
-
-
Save StephenRedd/759576341a330b51afb2756e255db9c2 to your computer and use it in GitHub Desktop.
powershell profile - Two-line informational prompt, posh-git, and more
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $doc = [Environment]::GetFolderPath("MyDocuments") | |
| New-Alias vs2019 $doc\PowerShell\vs2019.ps1 | |
| # Set-Alias code "$env:LOCALAPPDATA\Programs\Microsoft VS Code Insiders\Code - Insiders.exe" #"$env:Programfiles\Microsoft VS Code Insiders\bin\code-insiders.cmd" | |
| function code { | |
| #$code_path="$env:LOCALAPPDATA\Programs\Microsoft VS Code Insiders\Code - Insiders.exe" | |
| $code_path="C:\Program Files\Microsoft VS Code Insiders\Code - Insiders.exe" | |
| if ($args.Count -eq 0) { | |
| Start-Process -FilePath $code_path | |
| } else { | |
| Start-Process -FilePath $code_path -ArgumentList "$args" | |
| } | |
| } | |
| Set-Alias k "kubectl" | |
| Function tab($title) {$Host.UI.RawUI.WindowTitle=$title} | |
| Set-Alias wslfix "Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match 'Cisco AnyConnect'} | Set-NetIPInterface -InterfaceMetric 6000" | |
| Set-PSReadlineKeyHandler -Key Tab -Function Complete | |
| Import-Module cowsay | |
| if ($env:userprofile -eq (Get-Location).Path -or (Get-Location).Path -like "*PowerShell*"){ | |
| Set-Location C:\Users\steph\source\repos | |
| } | |
| # Don't load posh-git in the visual studio package manager console window | |
| if (!$profile.Contains("NuGet_profile")) { | |
| if (!(Get-Module -ListAvailable -Name posh-git)) { | |
| Write-Host "Module posh-git not installed, installing now:" | |
| Install-Module posh-git -Scope CurrentUser | |
| } | |
| if ($pshome -like "*syswow64*") { | |
| Write-Warning "running in 32 bit powershell" | |
| } | |
| Import-Module posh-git | |
| $ENV:STARSHIP_CONFIG = "$HOME\.starship.toml" | |
| Invoke-Expression (&starship init powershell) | |
| } | |
| function Touch-File() { | |
| $fileName = $args[0] | |
| # Check of the file exists | |
| if (-not(Test-Path $fileName)) { | |
| # It does not exist. Create it | |
| New-Item -ItemType File -Name $fileName | |
| } | |
| else { | |
| #It exists. Update the timestamp | |
| (Get-ChildItem $fileName).LastWriteTime = Get-Date | |
| } | |
| } | |
| ### Create an alias for touch | |
| # Check if the alias exists | |
| if (-not(Test-Path -Path Alias:Touch)) { | |
| New-Alias -Name Touch Touch-File -Force | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment