-
Notifications
You must be signed in to change notification settings - Fork 0
/
Microsoft.PowerShell_profile.ps1
138 lines (120 loc) · 3.88 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
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
########################################################
# Oscar Calvo's PowerShell Profile ([email protected])
#
$global:lastInvocation = $MyInvocation
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
}
}
}
$env:BUILD_TASKBAR_FLASH=1
$env:BUILD_DASHBOARD=1
$env:BUILD_LESS_OUTPUT=1
$env:MSBUILD_VERBOSITY='binlog'
$myHome = (get-item ~/.).FullName
$vimRC = ($myHome + '/_vimrc')
if (!(test-path $vimRC))
{
$_PsScriptRoot = $PSScriptRoot.Replace("\","/")
set-content -path $vimRC "source $_PsScriptRoot/profile.vim"
}
set-alias bcomp $env:ProgramFiles'/Beyond Compare 5/bcomp.com' -scope global
set-alias ztw '~/OneDrive/Apps/ZtreeWin/ztw64.exe' -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
#."$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" | 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
}
function global:Edit()
{
.$env:SDEDITOR $args
}
$_profileModulesPath = $PSScriptRoot+"/Modules"
if (!$env:PSModulePath.Contains($_profileModulesPath))
{
$separator = ";"
if (Test-IsUnix) { $separator = ":" }
$env:PSModulePath += $separator+$_profileModulesPath
}
[Console]::OutputEncoding = [Text.Encoding]::UTF8
if ($null -eq (get-command oh-my-posh -ErrorAction Ignore)) {
if (Test-IsUnix) {
$poshDir = "~/bin"
if ($notInPath) { $env:PATH += ":$poshDir" }
} else {
$poshDir = "$env:LOCALAPPDATA\Programs\oh-my-posh\bin"
if ($notInPath) { $env:PATH += ";$poshDir" }
}
}
if ($null -ne (get-command oh-my-posh -ErrorAction Ignore)) {
# $poshTheme = "Jandedobbeleer.omp.json"
$poshTheme = "markbull.omp.custom.yaml"
oh-my-posh init pwsh --config "$PSScriptRoot\PoshThemes\$poshTheme" | Invoke-Expression
} else {
# Fallback to old PowerShell Module
}
$serverModules = ($PSScriptRoot+'/../PSModules/Modules')
if (test-path $serverModules -ErrorAction Ignore)
{
$_fd = (get-item $serverModules).FullName
$env:psmodulepath+=(';'+$_fd)
get-content ($_fd+"/../.preload") -ErrorAction Ignore |% { Import-Module $_ }
}
Import-Module DirColors
#Import-Module PowerTab
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 ($null -eq $global:glyphs) {
# $glPath = Split-path (get-module Terminal-Icons).Path
# $global:glyphs = Invoke-Expression "& '$glPath/Data/glyphs.ps1'"
#}
if (!(Test-IsUnix))
{
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
}