-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMicrosoft.PowerShell_profile.ps1
More file actions
129 lines (101 loc) · 3.5 KB
/
Microsoft.PowerShell_profile.ps1
File metadata and controls
129 lines (101 loc) · 3.5 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")
# Load posh-git example profile
#. 'C:\Users\Ich\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1'
$env:path += ";" + (Get-Item "Env:ProgramFiles(x86)").Value + "\Git\bin"
$env:is_powershell = 1
# & 'D:\Progs\clink\0.4.9\clink_x64.exe' inject powershell.exe
# Load posh-git example profile
# . 'C:\Users\Freeo\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1'
function removesh
{
<#
.Synopsis
Removes sh.exe from $env:path.
#>
if (& which.exe sh.exe) {
$env:PATH=$env:PATH -replace ";C:\\Program Files `\(x86`\)\\Git\\bin", ""
echo "Remove sh.exe from `$env:path"
}
}
# My Aliases
function cd1up{Set-Location ..}
function cd2up{Set-Location ..\..}
function cd3up{Set-Location ..\..\..}
function cd4up{Set-Location ..\..\..\..}
Set-Alias cd.. cd1up
Set-Alias cd... cd2up
Set-Alias cd.... cd3up
Set-Alias cd..... cd4up
# Set-Alias geeknote C:\Python27\Scripts\geeknote.exe
# writing help:
# begin with multiline comment
# use special help tags (synopsis is displayed in every help call)
#
# getting help:
# Get-Help myfunction (-parameter)
# parameters:
# -detailed -full
function gcaladd($msg){
<#
.Synopsis
Usage:
google calendar add "calender entry (msg) 2014-12-5"
December is a special case. This works for all months except December:
google calendar add "calender entry (msg) November 5"
Alias:
gcal = google calendar add
gcal "calender entry (msg) 2014-12-5"
.Notes
Non working examples:
gcal calender entry (msg) 2014-12-5
(missing quotes)
gcal "calender entry (msg) 2014-12-05"
(05 won't be parsed)
#>
E:\google_cl\google.exe calendar add $msg}
set-alias gcal gcaladd
Import-Module posh-git
Import-Module oh-my-posh
# Set-Theme kalisi # outdated structure! oh-my-posh switched from psm1 to json
Set-PoshPrompt negligible
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
function Get-GitStatus { & git status $args }
New-Alias -Name gs -Value Get-GitStatus
Import-Module PSReadLine
Set-PSReadLineOption -EditMode Vi
Set-PSReadLineOption -ViModeIndicator Cursor
# https://stackoverflow.com/questions/39547321/rebind-escape-in-psreadline-for-vi-mode
# This may cause problems with pasting 'j', however.
Set-PSReadLineKeyHandler -Chord 'j' -ScriptBlock {
if ([Microsoft.PowerShell.PSConsoleReadLine]::InViInsertMode()) {
$key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
if ($key.Character -eq 'k') {
[Microsoft.PowerShell.PSConsoleReadLine]::ViCommandMode()
}
else {
[Microsoft.Powershell.PSConsoleReadLine]::Insert('j')
[Microsoft.Powershell.PSConsoleReadLine]::Insert($key.Character)
}
}
}
function gitmoji-commit { & gitmoji -c }
New-Alias -Name gmc -Value gitmoji-commit
function ZtoJ { & z $args }
New-Alias -Name j -Value ZtoJ
# remap of RightArrow doesn't work yet, beta.
# https://github.com/PowerShell/PSReadLine/issues/687
# Set-PSReadLineKeyHandler -Key "Shift+Tab" -Function AcceptSuggestion
New-Alias -Name ranger -Value lf
New-Alias -Name rcd -Value lf
$ENV:EDITOR = "C:/tools/neovim/nvim-win64/bin/nvim.EXE"
# zoxide
Invoke-Expression (& {
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
(zoxide init --hook $hook powershell) -join "`n"
})
Invoke-Expression (& { (zoxide init powershell | Out-String) })
echo "Loaded my profile"