-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_once_before_main.ps1
122 lines (106 loc) · 3.57 KB
/
run_once_before_main.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
using namespace System.Security.Principal
[CmdletBinding()]
param()
begin {
function MaybeInstallScoopApp {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[string] $Name,
[Parameter()]
[AllowNull()]
[AllowEmptyString()]
[string] $Application
)
process {
if (-not $Application) {
$Application = $Name
}
if (Get-Command $Application -CommandType Application -ErrorAction Ignore) {
return
}
scoop install $Name
}
}
}
end {
scoop bucket add extras
MaybeInstallScoopApp 7zip 7z
$scoopApps = @(
'bat'
'less'
'gh'
'gpg'
'wsl-ssh-pageant'
'python'
'gzip'
'tar'
'wget'
'sed'
'fzf'
'htmlq'
'delta'
'clangd'
)
foreach ($app in $scoopApps) {
MaybeInstallScoopApp $app
}
scoop install flow-launcher
scoop install https://gist.github.com/SeeminglyScience/8dc717be6e6d362ad65efbdf124922b8/raw/psudad.json
if ([WindowsIdentity]::GetCurrent().Owner.IsWellKnown([WellKnownSidType]::BuiltinAdministratorsSid)) {
& "$PSScriptRoot\admin_tasks.ps1"
} else {
Start-Process powershell -Verb RunAs -Wait -ArgumentList (
'-NoLogo',
'-NoProfile',
'-ExecutionPolicy Bypass',
'-File', ('"{0}\admin_tasks.ps1"' -f $PSScriptRoot))
}
MaybeInstallScoopApp bitwarden-cli bw
$env = @{
'SSH_AUTH_SOCK' = '\\.\pipe\ssh-pageant'
'GIT_SSH' = 'C:\Windows\System32\OpenSSH\ssh.exe'
'LESS' = '--quiet --raw-control-chars --quit-on-intr --ignore-case --prompt :'
'LESSCHARSET' = 'utf-8'
'CLASS_EXPLORER_TRUE_CHARACTER' = [char]0x2713 # check mark
'BAT_THEME' = 'Visual Studio Dark+'
'BAT_PAGER' = 'less --quiet --raw-control-chars --quit-on-intr --ignore-case --prompt : --no-init --chop-long-lines'
}
foreach ($kvp in $env.GetEnumerator()) {
[Environment]::SetEnvironmentVariable($kvp.Name, $kvp.Value, [EnvironmentVariableTarget]::User)
}
if (-not (Get-Module -ListAvailable Microsoft.PowerShell.PSResourceGet)) {
& "$env:ProgramFiles\PowerShell\7\pwsh.exe" -NoProfile {
Install-Module Microsoft.PowerShell.PSResourceGet -Scope CurrentUser -AllowPrerelease -SkipPublisherCheck
}
}
& "$env:ProgramFiles\PowerShell\7\pwsh.exe" -NoProfile {
$modules = (
'ClassExplorer',
'EditorServicesCommandSuite',
'ScriptBlockDisassembler',
'ImpliedReflection',
'ILAssembler',
'ImportExcel',
'InvokeBuild',
'platyPS',
'ProcessEx',
'PSFzf',
'PSLambda',
'PSScriptAnalyzer',
'ThreadJob',
'PSEverything',
'Microsoft.PowerShell.SecretManagement',
'Microsoft.PowerShell.SecretStore')
$existingModules = Get-Module -ListAvailable |
Group-Object Name |
Select-Object -ExpandProperty Name
foreach ($module in $modules) {
if ($module -in $existingModules) {
continue
}
Install-PSResource $module -Prerelease -Scope CurrentUser -TrustRepository -AcceptLicense
}
}
}