Skip to content

Commit 0feffb0

Browse files
committed
🔨 chore: rewrite Update-Windots function and cleanup posh-aliases.ps1 file
1 parent b5c731f commit 0feffb0

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

dotposh/Config/posh-aliases.ps1

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,3 @@ Add-Alias profiles 'Get-PSProfile {$_.exists -eq "True"} | Format-List'
185185

186186
Add-Alias HKLM: 'Set-Location HKLM:'
187187
Add-Alias HKCU: 'Set-Location HKCU:'
188-
189-
190-
# ----------------------------------------------------------------------------------- #
191-
# Dotfiles related
192-
function Update-Dotfiles {
193-
$currentLocation = "$(Get-Location)"
194-
Write-Host "Updating windots..."
195-
Set-Location "$env:DOTFILES"
196-
git stash | Out-Null
197-
git pull | Out-Null
198-
git stash pop | Out-Null
199-
Start-Process pwsh -ArgumentList "./Setup.ps1" -Verb RunAs -WindowStyle Hidden -Wait
200-
Set-Location $currentLocation
201-
. $PROFILE.CurrentUserAllHosts
202-
}
203-
Set-Alias -Name 'dotu' -Value 'Update-Dotfiles'
204-
205-

dotposh/Config/update-windots.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# cSpell:disable
2+
3+
function Update-Windots {
4+
[CmdletBinding()]
5+
$currentDir = "$(Get-Location)"
6+
7+
Set-Location "$env:DOTFILES"
8+
git stash | Out-Null
9+
git pull | Out-Null
10+
git stash pop | Out-Null
11+
12+
if ((New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -eq $False) {
13+
if (Get-Command gsudo -ErrorAction SilentlyContinue) {
14+
gsudo .\Setup.ps1
15+
}
16+
else {
17+
Start-Process pwsh -ArgumentList ".\Setup.ps1" -Verb RunAs -WindowStyle Hidden -Wait
18+
}
19+
}
20+
21+
Set-Location $currentDir
22+
. $PROFILE.CurrentUserAllHosts
23+
}
24+
25+
Set-Alias -Name 'dotupdate' -Value 'Update-Windots'

0 commit comments

Comments
 (0)