Last active
August 4, 2022 11:10
-
-
Save NetzwergX/032eaed6f99487ba277407ba2f456f07 to your computer and use it in GitHub Desktop.
My PowerShell Profile -- includes oh-my-posh and auto completion for git, docker and dotnet and suggestions from history
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
# SETUP: | |
# Install-Module posh-git -Scope CurrentUser | |
# Install-Module Terminal-Icons -Scope CurrentUser | |
# winget install JanDeDobbeleer.OhMyPosh -s winget | |
# Install-Module DockerCompletion -Scope CurrentUser | |
# Install-Module -Name PSReadLine -Scope CurrentUser | |
# Install-Module oh-my-posh -Scope CurrentUser | |
# TODO: https://ohmyposh.dev/docs/migrating | |
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding | |
# PowerShell parameter completion shim for the dotnet CLI | |
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock { | |
param($commandName, $wordToComplete, $cursorPosition) | |
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object { | |
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | |
} | |
} | |
Import-Module Terminal-Icons | |
Import-Module posh-git # git autocpmpletion, c.f. https://github.com/dahlbyk/posh-git | |
Set-PoshPrompt -Theme ~/.oh-my-posh.omp.json | |
Import-Module DockerCompletion # completion for docker commands | |
Set-PSReadLineOption -PredictionSource History | |
# My POSIX-like `touch` utility | |
function Set-LastWriteTime | |
{ | |
$file = $args[0] | |
if ($null -eq $file) { | |
Write-Error "Filename not specified." -ErrorAction:Stop | |
} | |
if (Test-Path $file) | |
{ | |
(Get-ChildItem $file).LastWriteTime = Get-Date | |
} | |
else | |
{ | |
Add-Content $file $null | |
} | |
} | |
New-Alias -Name touch Set-LastWriteTime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment