-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake.ps1
208 lines (184 loc) · 4.69 KB
/
make.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# DO NOT RUN ON ISE
# Set-ExecutionPolicy -Scope Process Unrestricted
$DOTFILES = "$env:USERPROFILE\.dotfiles"
$EMACSD= "$env:USERPROFILE\.emacs.d"
# Chocolatey
try {
Get-Command -Name choco -ErrorAction Stop
}
catch [System.Management.Automation.CommandNotFoundException] {
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
$CHOCO_PACKAGES = @(
# "dropbox"
# "googlechrome"
# "vscode"
# "1password"
# "vagrant"
# "virtualbox"
# "docker-desktop"
# "discord"
# "line"
# "zoom"
# "windirstat"
# "autohotkey"
# "adobereader"
# "rapidee"
# "vlc"
# "licecap"
"synologydrive"
# "qttabbar"
"cica"
"cascadiacodepl"
"font-hackgen-nerd"
# "steam"
)
choco update
choco install -y $CHOCO_PACKAGES
# Scoop
try {
Get-Command -Name scoop -ErrorAction Stop
}
catch [System.Management.Automation.CommandNotFoundException] {
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
}
$SCOOP_PACKAGES = @(
"7zip"
"bat"
"concfg"
"emacs"
"everything"
"fd"
"fzf"
"gawk"
"ghq"
"git"
"go"
"gzip"
"hub"
"jq"
"less"
"mpc-be"
# "nodejs-lts"
"openssh"
# "paint.net"
# "powertoys"
# "pshazz"
"pt"
"pwsh"
"ripgrep"
"ruby"
"sed"
"sudo"
"sysinternals"
"tar"
"uutils-coreutils"
"windows-terminal"
)
scoop install git
scoop update
scoop bucket add extras
scoop bucket add versions
scoop update *
scoop install $SCOOP_PACKAGES
scoop cache rm *
# https://github.com/lukesampson/scoop/wiki/Theming-Powershell
concfg import dracula
winget install JanDeDobbeleer.OhMyPosh -s winget
if (Test-Path ("$DOTFILES")) {
Set-Location $DOTFILES
git pull
}
else {
git config --global core.autoCRLF false
git clone https://github.com/hushin/dotfiles-windows $DOTFILES
}
# # spacemacs
# if (Test-Path ("$EMACSD")) {
# Set-Location $EMACSD
# git pull
# }
# else {
# cd $env:USERPROFILE
# git clone --depth 1 https://github.com/doomemacs/doomemacs .config/emacs
# }
[System.Environment]::SetEnvironmentVariable("HOME", "$env:USERPROFILE", "User")
# profile
$PSUSERHOME = $profile -replace "^(.*)\\.*$", "`$1" -replace "^(.*)\\.*$", "`$1"
## Windows Powershell
New-Item $PSUSERHOME\WindowsPowerShell -Force -ItemType Directory
## Powershell Core
New-Item $PSUSERHOME\PowerShell -Force -ItemType Directory
# Windows Terminal
New-Item -Path $env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState -Force -ItemType Directory
# keyhac
New-Item $PSUSERHOME\bin\keyhac -Force -ItemType Directory
# AutoHotKey
New-Item $PSUSERHOME\SetUp\AutoHotKey -Force -ItemType Directory
# keyhac Shortcut
$WsShell = New-Object -ComObject WScript.Shell
$Shortcut = $WsShell.CreateShortcut("$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\keyhac.lnk")
$Shortcut.TargetPath = "$PSUSERHOME\bin\keyhac\keyhac.exe"
$Shortcut.IconLocation = "$PSUSERHOME\bin\keyhac\keyhac.exe"
$Shortcut.WindowStyle = 7 #最小化
$Shortcut.Save()
# memo
New-Item -Path $env:APPDATA\memo -Force -ItemType Directory
# ssh
New-Item -Path $env:USERPROFILE\.ssh -Force -ItemType Directory
# runas
Start-Process powershell.exe ("-NoProfile -Command cd " + $env:USERPROFILE + "\.dotfiles; .\runas.ps1") -Verb runas
# PowerShell
echo "Install posh-git"
Install-Module posh-git -Scope CurrentUser
# echo "Install oh-my-posh"
# Install-Module oh-my-posh -Scope CurrentUser
echo "Install ZLocation"
Install-Module ZLocation -Scope CurrentUser
echo "Install PSFzf"
Install-Module PSFzf -Scope CurrentUser
# ruby
# $GEMPACKAGES = @(
# "git-browse-remote"
# )
# gem install $GEMPACKAGES
# nodejs
# $NPMPACKAGES = @(
# "npm-check-updates"
# "http-server"
# "npm"
# "init-package-json-parcel"
# "prettier"
# )
# foreach ($NPMPACKAGE in $NPMPACKAGES) {
# npm install -g $NPMPACKAGE
# }
# golang
# $GOPACKAGES = @(
# "github.com/mattn/memo"
# )
# Set-Location $env:USERPROFILE
# foreach ($GOPACKAGE in $GOPACKAGES) {
# go get -u $GOPACKAGE
# }
# gitconfig for windows
if (!(Test-Path -Path $env:USERPROFILE\.gitconfig.local)) {
New-Item -Path $env:USERPROFILE\.gitconfig.local
}
# deprecated
$deprecated_files = @(
"$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\profiles.json"
)
foreach ($deprecated_file in $deprecated_files) {
if (Test-Path -PathType Leaf $deprecated_file) {
Remove-Item -Force $deprecated_file
}
}
$deprecated_dirs = @(
"$env:APPDATA\Hyper"
)
foreach ($deprecated_dir in $deprecated_dirs) {
if (Test-Path -PathType Container $deprecated_dir) {
Remove-Item -Force -Recurse $deprecated_dir
}
}