-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrosoft.PowerShell_profile.ps1
62 lines (46 loc) · 1.76 KB
/
Microsoft.PowerShell_profile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# posh config
try {
oh-my-posh init pwsh | Invoke-Expression
} catch { } # squelch errors from multiple runs in same shell
# Kenneth Ko Powershell aliases file for windows
# first draft
# last updated
# 20231225
#
# typical target:
# ~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# via
set-alias vi vim
function via { vi $profile; & $profile }
# NOTE - source only picks up new functions. It doesn't seem to overwrite old ones
function pba { cat $profile | Set-Clipboard }
# bash behavior
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
function pbcopy {
[CmdletBinding()] param(
[Parameter(ValueFromPipeline)]
$text
)
Process { $text | Set-Clipboard; $text }
}
set-alias pbpaste Get-Clipboard
set-alias ll dir
function l { Get-ChildItem $args -Exclude .* | Format-Wide Name -AutoSize }
set-alias grep select-string
function which { (gcm $args).Path }
# NOTE - to edit registry from an admin console:
# New-ItemProperty -Path "" -Name "" -PropertyType DWord -Value "00000001";
# Set-ItemProperty -Path "" -Name "" -Value "00000001";
# ./taskkill /f /im explorer.exe; ./CMD /Q /C START /REALTIME explorer.exe;
#
# Registry preferences
# HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced LastActiveClick
# convenience methods
function td { Get-Date -Format "yyyyMMdd" | pbcopy }
function tt { Get-Date -Format "yyyyMMdd HHmm" | pbcopy }
function pbjson { pbpaste | ConvertFrom-Json | ConvertTo-Json -Depth 10 }
function gf { git fetch origin master }
function gg { gf; git merge master }
function gs { git switch -c $args remotes/origin/$args }
function gt { gf; git merge $(git describe origin/master --tags --abbrev=0) }
function gb { gf; git checkout -b $args $(git describe origin/master --tags --abbrev=0) }