Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| powershell_configuration [2021/10/22 18:05] – created mgupton | powershell_configuration [2022/04/08 12:54] (current) – mgupton | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Powershell Configuration ====== | ====== Powershell Configuration ====== | ||
| + | |||
| + | List environment variables | ||
| + | < | ||
| + | gci env: | ||
| + | </ | ||
| To get $path variable | To get $path variable | ||
| Line 7: | Line 12: | ||
| To edit Powershell profile | To edit Powershell profile | ||
| - | < | + | < | 
| notepad $PROFILE | notepad $PROFILE | ||
| + | </ | ||
| + | |||
| + | Dot (.) source to reload $PROFILE into current sessions, just like Bash | ||
| + | <code powerhell> | ||
| + | . $profile | ||
| + | </ | ||
| + | |||
| + | Get path to command history file | ||
| + | <code powershell> | ||
| + | (Get-PSReadlineOption).HistorySavePath | ||
| + | </ | ||
| + | |||
| + | === Reference Config === | ||
| + | |||
| + | <code powershell> | ||
| + | $env:Path += "; | ||
| + | $od = " | ||
| + | Import-Module posh-git | ||
| + | Import-Module oh-my-posh | ||
| + | Set-PoshPrompt -Theme mg | ||
| + | |||
| + | $host.PrivateData.ErrorForegroundColor = ' | ||
| + | $host.PrivateData.ErrorBackgroundColor = ' | ||
| + | |||
| + | set-alias exp explorer.exe | ||
| + | set-alias gs git-save | ||
| + | set-alias gd git-dump | ||
| + | set-alias mgi c: | ||
| + | set-alias npp notepad++.exe | ||
| + | |||
| + | Set-PSReadLineOption -HistoryNoDuplicates | ||
| + | |||
| + | function npw() { | ||
| + | param( | ||
| + | [Parameter(Position=0)] | ||
| + | $folder | ||
| + | ) | ||
| + |     Start-Process notepad++.exe -ArgumentList " | ||
| + | } | ||
| + | |||
| + | function h2 { | ||
| + |     notepad (Get-PSReadLineOption | select -ExpandProperty HistorySavePath)  | ||
| + | } | ||
| + | |||
| + | function h3 { | ||
| + |     code -n (Get-PSReadLineOption | select -ExpandProperty HistorySavePath)  | ||
| + | } | ||
| + | |||
| + | function hp { | ||
| + | Get-History | | ||
| + | Out-GridView -Title "Press CTRL, select multiple and Hit OK" -OutputMode Multiple | | ||
| + | ForEach-Object { | ||
| + |         Write-Output " | ||
| + |         Invoke-Expression $($_.CommandLine)  | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function hpp { | ||
| + | Start-Process notepad++.exe (Get-PSReadlineOption).HistorySavePath | ||
| + | } | ||
| + | |||
| + | function git-dump([Parameter(Mandatory=$true)][string]$commit, | ||
| + |     $temp_file=" | ||
| + | } | ||
| + | |||
| + | function git-save { | ||
| + | git add .; git commit | ||
| + | } | ||
| + | |||
| + | function mgl { | ||
| + | git log | ||
| + | } | ||
| + | |||
| + | function git-ls($commit) { | ||
| + | git ls-tree --name-only -r $commit | ||
| + | } | ||
| + | |||
| + | function git-show($commit) { | ||
| + | git show --name-only $commit | ||
| + | } | ||
| </ | </ | ||