-
Notifications
You must be signed in to change notification settings - Fork 1
/
update-windots.ps1
92 lines (68 loc) · 3.43 KB
/
update-windots.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
# cSpell:disable
# function runsetup {
# gsudo "$env:DOTFILES\Setup.ps1"
# }
# function Update-Windots {
# # Check if `gum` command exists, else exit
# if (-not (Get-Command gum -ErrorAction SilentlyContinue)) {
# Write-Warning "Command not found: gum. Exiting..."
# return
# }
# $currentDir = "$(Get-Location)"
# Set-Location "$env:DOTFILES"
# # Update local profile with GitHub repository
# gum spin --title="Stashing GitHub repo..." --title.foreground="#b4befe" --spinner.foreground="#cba6f7" --show-error -- git stash
# gum spin --title="Pulling latest updates..." --title.foreground="#b4befe" --spinner.foreground="#cba6f7" --show-error -- git pull
# gum spin --title="Updating local windots..." --title.foreground="#b4befe" --spinner.foreground="#cba6f7" --show-error -- git stash pop
# # WinGet
# # gum spin --title="Updating WinGet packages..." --title.foreground="#b4befe" --spinner.foreground="#cba6f7" --show-error -- winget update --all --accept-package-agreements --accept-source-agreements
# # scoop
# # gum spin --title="Updating scoop packages..." --title.foreground="#b4befe" --spinner.foreground="#cba6f7" --show-error -- scoop update --all
# # Clearing oh-my-posh cache files
# # gum spin --title="Clearing oh-my-posh cache..." --title.foreground="#b4befe" --spinner.foreground="#cba6f7" --show-error -- oh-my-posh cache clear
# # Updating wsl
# # gum spin --title="Updating WSL..." --title.foreground="#b4befe" --spinner.foreground="#cba6f7" --show-error -- wsl --update --pre-release
# # Write-Verbose "Capturing any new dependencies"
# # if (Get-Command gsudo -ErrorAction SilentlyContinue) {
# # gsudo .\Setup.ps1
# # }
# # else {
# # Start-Process pwsh -ArgumentList ".\Setup.ps1" -Verb RunAs -WindowStyle Hidden -Wait
# # }
# Set-Location $currentDir
# Write-Verbose "Reloading PowerShell profile"
# . $PROFILE.CurrentUserAllHosts
# }
# Set-Alias -Name 'dotupdate' -Value 'Update-Windots'
function Update-Windots {
$currentDir = "$(Get-Location)"
. "$env:DOTFILES\Functions.ps1"
# Update local profile with GitHub repository
Set-Location "$env:DOTFILES"
gum spin --title="Stashing GitHub repo..." --show-error -- git stash
gum spin --title="Pulling latest updates..." --show-error -- git pull
gum spin --title="Updating local windots..." --show-error -- git stash pop
# Update winget packages
if (Get-Command winget -ErrorAction SilentlyContinue) {
gum spin --title="Updating winget packages..." -- winget update --all
}
# Update scoop packages
if (Get-Command scoop -ErrorAction SilentlyContinue) {
gum spin --title="Updating scoop apps..." -- scoop update --all
}
if (Get-Command oh-my-posh -ErrorAction SilentlyContinue) {
gum spin --title="Clearning oh-my-posh cache..." -- oh-my-posh cache clear
}
# Update vscode extensions
if (Get-Command code -ErrorAction SilentlyContinue) {
gum spin --title="Updating vscode extensions..." -- code --update-extensions
}
# Update github cli extensions
if (Get-Command gh -ErrorAction SilentlyContinue) {
gum spin --title="Updating gh extensions..." -- gh extension upgrade --all
}
Set-Location "$currentDir"
Write-Verbose "Reloading PowerShell profile"
. $PROFILE.CurrentUserAllHosts
}
Set-Alias -Name 'dotupdate' -Value 'Update-Windots'