-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMicrosoft.PowerShell_profile.ps1
More file actions
154 lines (129 loc) · 4.69 KB
/
Microsoft.PowerShell_profile.ps1
File metadata and controls
154 lines (129 loc) · 4.69 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
########################################################
# Oscar Calvo's PowerShell Profile ([email protected])
#
[CmdLetBinding()]
param()
$global:lastInvocation = $MyInvocation
$global:__platform = switch -Regex ([System.Runtime.InteropServices.RuntimeInformation]::OSDescription) {
'Windows' { 'Windows' }
'Darwin' { 'macOS' }
'Linux' { 'Linux' }
'Ubuntu' { 'Linux' }
default { 'Unknown OS' }
}
Write-Verbose "Detected platform:$global:__platform"
function global:Test-IsUnix {
return (($PSVersionTable.PSEdition -eq 'Core') -and ($PSVersionTable.Platform -eq 'Unix'))
}
function global:test-isadmin {
$isUnix = Test-IsUnix
if ($isUnix) {
return ((id -u) -eq 0)
} else {
if ("ConstrainedLanguage" -eq $ExecutionContext.SessionState.LanguageMode) {
return $false
}
try {
$wi = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$wp = new-object 'System.Security.Principal.WindowsPrincipal' $wi
return $wp.IsInRole("Administrators") -eq 1
} catch {
return $false
}
}
}
if (-Not (Test-Path env:TEMP) -And (Test-Path env:TMPDIR)) {
$env:TEMP = $env:TMPDIR
$env:TMP = $env:TMPDIR
}
$env:AppxSymbolPackageEnabled='false'
$env:MSBUILDLOGALLENVIRONMENTVARIABLES=1
$myHome = (get-item ~/.).FullName
$vimRC = ($myHome + '/_vimrc')
if (!(test-path $vimRC))
{
$_PsScriptRoot = $PSScriptRoot.Replace("\","/")
set-content -path $vimRC "source $_PsScriptRoot/profile.vim"
}
$__bcomp = if ($global:__platform -eq "macOS") {
"/Applications/Beyond Compare.app/Contents/MacOS/bcomp"
} elseif ($global:__platform -eq "Linux") {
(get-command bcompare).definition
} else {
"$env:ProgramFiles/Beyond Compare 5/bcomp.com"
}
set-alias bcomp $__bcomp -scope global
set-alias speak "$PSScriptRoot\Speak.ps1" -scope global
set-alias Parse-GitCommit "$PSScriptRoot\Parse-GitCommit.ps1" -scope global
set-alias Get-GitCommit "$PSScriptRoot\Get-GitCommit.ps1" -scope global
set-alias Set-PrivateKeyPermissions "$PSScriptRoot\Set-PrivateKeyPermissions.ps1" -scope global
set-alias test-nsfw "$PSScriptRoot\Test-NSFW.ps1" -scope global
set-alias Get-NSFWProperties "$PSScriptRoot\Get-NSFWProperties.ps1" -scope global
if ("Windows" -eq $global:__platform) {
set-alias ztw '~/OneDrive/Apps/ZtreeWin/ztw64.exe' -scope global
$env:DOCKER_HOST="tcp://127.0.0.1:2375"
set-alias docker "$PSScriptRoot\Invoke-Docker.ps1" -scope global
}
."$PSScriptRoot\Set-GitConfig.ps1"
# SD settings
$vimCmd = get-command vim -ErrorAction Ignore
$codeCmd = get-command code -ErrorAction Ignore
if ($null -eq $vimCmd)
{
$vimExe = dir "C:\Program Files\Vim\vim*\vim.exe" -ErrorAction Ignore | select -first 1
$vimPath = $vimExe.Directory.FullName
$env:path += ";$vimPath"
$vimCmd = get-command vim -ErrorAction Ignore
}
if (($null -ne $codeCmd) -and ($env:TERM_PROGRAM -eq "vscode"))
{
$env:SDEDITOR=$codeCmd.definition
$env:SDUEDITOR=$codeCmd.definition
}
elseif ($null -ne $vimCmd)
{
$env:SDEDITOR=$vimCmd.definition
$env:SDUEDITOR=$vimCmd.definition
}
$env:BUILD_CUSTOM_PARAM01 = "TV"
$env:BUILD_DEFAULT_TARGET = "Apps\{0}\{0}Package"
$env:BUILD_APPX_RECIPE = ".\BuildResults\{0}-{1}\{2}Package\bin\{2}Package\{2}Package.build.appxrecipe"
$env:PlatformToolset="v145" # Force VS2026
function global:Edit()
{
.$env:SDEDITOR $args
}
$separator = ";"
if (Test-IsUnix) { $separator = ":" }
$_profileModulesPath = $PSScriptRoot+"/Modules"
if (!$env:PSModulePath.Contains($_profileModulesPath))
{
$newModPath = $separator+$_profileModulesPath
Write-Verbose "Adding new module path:$newModPath"
$env:PSModulePath += $newModPath
}
[Console]::OutputEncoding = [Text.Encoding]::UTF8
."$PSScriptRoot\PoshThemes\load.ps1"
$serverModules = ($PSScriptRoot+'/../PSModules/Modules')
Write-Verbose "Probing module path:$serverModules"
if (test-path $serverModules -ErrorAction Ignore)
{
$_fd = (get-item $serverModules).FullName
$env:PSModulePath+=($separator+$_fd)
get-content ($_fd+"/../.preload") -ErrorAction Ignore |% { Import-Module $_ }
}
Import-Module PSReadLine
Set-PSReadLineOption –HistoryNoDuplicates:$True
Set-PSReadLineOption -PredictionSource History
Import-Module PwrSudo
Import-Module PwrSearch
Import-Module PwrDev
Import-Module PwrRazzle
Import-Module Terminal-Icons
if (!(Test-IsUnix)) {
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
}